simLMM {designr} | R Documentation |
Simulate data from a linear mixed-effects model
Description
This function simulates artificial data from a linear mixed-effects model. Parameters can either be set by hand using the parameters listed below *or* using a fitted lmerMod
object.
Usage
simLMM(
formula,
data = NULL,
Fixef,
VC_sd,
CP = 0,
LMM = NULL,
empirical = FALSE,
verbose = TRUE,
family = "gaussian"
)
Arguments
formula |
A formula as used in a call to the |
data |
a data frame containing the variables named in |
Fixef |
a vector of all fixed-effect model parameters. |
VC_sd |
standard deviations of the variance components for the random effects. This is a list of vectors, where different list entries reflect different grouping structures, and each vector contains standard deviations of variance components (random intercepts and random slopes) for one grouping factor. The last list entry is the standard deviation of the residual noise term (for |
CP |
correlation parameters of the random effects. If |
LMM |
if a |
empirical |
logical. If true, |
verbose |
logical. If |
family |
string specifying the response distribution: |
Examples
design <-
fixed.factor("X", levels=c("X1", "X2")) +
random.factor("Subj", instances=30)
dat <- design.codes(design)
contrasts(dat$X) <- c(-1, +1)
dat$ysim <- simLMM(formula = ~ 1 + X + (1 + X | Subj),
data = dat,
Fixef = c(200, 10),
VC_sd = list(c(30,10), 50),
CP = 0.3,
empirical = TRUE)
dat$Xn <- ifelse(dat$X=="X1",-1,1)
# lme4::lmer(ysim ~ Xn + (Xn || Subj), data=dat, control=lmerControl(calc.derivs=FALSE))