EAMM {pamm} | R Documentation |
Simulation function for exploratory power analysis for random effects
Description
Given a specific sample size, fixed number of group and replicates per group, the function simulate different variance-covariance structure and assess p-values and power of random intercept and random slope
Usage
EAMM(
numsim,
group,
repl,
fixed = c(0, 1, 0),
VI = seq(0.05, 0.95, 0.05),
VS = seq(0.05, 0.5, 0.05),
CoIS = 0,
relIS = "cor",
n.X = NA,
autocorr.X = 0,
X.dist = "gaussian",
intercept = 0,
heteroscedasticity = c("null"),
mer.sim = TRUE,
mer.model = NULL
)
Arguments
numsim |
number of simulation for each step |
group |
number of group |
repl |
number of replicates per group |
fixed |
vector of lenght 3 with mean, variance and estimate of
fixed effect to simulate. Default: |
VI |
variance component of intercept. Could be specified as a
vector. Default: |
VS |
Variance component of the slope or IxE. Could be specified as a vector.
Default: |
CoIS |
value of correlation or covariance between random intercept and random slope. Default: 0 |
relIS |
"cor" or "cov" set the type of relation give in CoIS. By default the relation is set to correlation |
n.X |
number of different values to simulate for the fixed effect (covariate).
If |
autocorr.X |
correlation between two successive covariate value for a group. Default: |
X.dist |
specify the distribution of the fixed effect. Only "gaussian" (normal distribution) and
"unif" (uniform distribution) are accepted actually. Default: |
intercept |
a numeric value giving the expected intercept value. Default: 0 |
heteroscedasticity |
a vector specifying heterogeneity in residual
variance across X. If |
mer.sim |
Use the simluate.merMod function to simulate the data. Potentially faster for large dataset but more restricted in terms of options |
mer.model |
Simulate the data based on a existing data and model structure from a lmer object. Should be specified as a list of 3 components: a mer object fitted via lmer, an environmental covariate for which to test the random slope, a random effect (e.g. |
Details
P-values for random effects are estimated using a log-likelihood ratio test between two models with and without the effect. Power represent the percentage of simulations providing a significant p-value for a given random structure. Residual variance, e, is calculted as 1-VI.
Value
data frame reporting estimated P-values and power with CI for random intercept and random slope
See Also
[PAMM()], [SSF()] for other simulations [plot.EAMM()] for plotting output
Examples
## Not run:
ours <- EAMM(
numsim = 10, group = 10, repl = 4, fixed = c(0, 1, 1),
VI = seq(0.1, 0.3, 0.05), VS = seq(0.05, 0.2, 0.05)
)
plot(ours, "both")
(fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy))
ours2 <- EAMM(
numsim = 10,
mer.model = list(model = fm1, env = "Days", random = "Subject"),
VI = seq(0.3, 0.5, 0.1), VS = seq(0.05, 0.2, 0.05)
)
plot(ours2, "both")
## End(Not run)