Does my model work as expected?
Baseline coverage: In a null simulation, does my confidence interval contain the right answer (β=0) \(1-\alpha\) of the time?
General coverage: In a range of simulations, does my confidence interval contain the right answer (β=0) \(1-\alpha\) of the time?
Do I have good design and sample size?
Are my confidence intervals likely to be small enough to provide useful information?
If my scientific hypothesis is correct, are my confidence intervals likely to exclude a null effect?
What are some dangers of not having enough power?
expand.grid
,
sample
, seq()
, rep()
,
r*
functionsr*
functions)mu
;
size
is the dispersion parameter, smaller means more
variability (mean = \(\mu
(1+\mu/k)\)).meanlog
, sdlog
are the mean
and SD on the log scalesimulate
samples new values based on a
fitted modelsimulate()
(in lme4
) and
simulate_new()
(in glmmTMB
) can simulate
values de novo, by specifying covariates and parameter
valuesFor example:
data("sleepstudy", package = "lme4")
set.seed(101)
library(glmmTMB)
y <- simulate_new( ~ Days + (Days | Subject),
nsim = 1,
family = "gaussian",
newdata = sleepstudy, ## covariates
newparams = list(
beta = c(250, 10), ## intercept and slope (pop-level)
## log-SD of intercept and slope; transformed correlation
theta = c(2, 1, 0),
betad = 2) ## log-SD of residual variation
)[[1]] ## simulate_new always returns a list
The hardest part is understanding the random-effects parameters
(theta
); see here
or ask us.
Since glmmTMB
can handle models with or without random
effects, and a wide range of GLM-type distributions, this may be a good
way to simulate responses once you’ve simulated your experimental
design/covariate distribution.