Description Usage Arguments Details Value See Also Examples
View source: R/functions_exposure_simulation.R
Draws a sample of exposure observations using the specified model parameters
1 |
obj |
exposure simulation object, created by |
This function assumes that etaG
, sigW
, reI
, and timefn
have been set. Optionally, sigK
should be set if a cluster random effect is to be included. These can be set with expsim_update_parameter
. Using these values, it first computes the (conditional) observation mean, with is
An object of class expsim
, with updated values of obj$standata$w
and obj$structure$meanW
.
Other exposure simulation functions:
create_exposure_simulation_skeleton()
,
expsim_update_parameter()
,
sim_update_times()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | es <- create_exposure_simulation_skeleton_parallel(ngroups=2,
nclusters=15,
nunits=10,
nobs=2)
# Set group means
es <- expsim_update_parameter(es,
level="group",
type="mean",
value=c(3, 4))
# Set unit random effect standard deviation
es <- expsim_update_parameter(es,
level="unit",
type="sd",
value=c(1))
# Set observation standard deviation
es <- expsim_update_parameter(es,
level="observation",
type="sd",
value=c(1))
# Sample unit random effects
es <- expsim_update_parameter(es,
level="unit",
type="re")
# Compute (conditional) observation means and sample observations
expsim_demo <- expsim_sample_observations(es)
str(expsim_demo$structure$meanW)
str(expsim_demo$standata$w)
# Add priors and estimate parameters
expsim_demo$standata <- add_priors(expsim_demo$standata)
fit <- sample_exposure_model(expsim_demo$standata)
print(fit, pars=c("reI_raw", "muW", "reI", "reK", "reK_raw"), include=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.