If pilot data is not available, simr
can be
used to create lme4
objects from scratch as a starting
point. This requires more paramters to be specified by the user. Values
for these parameters might come from the literature or the user’s own
knowledge and experience.
First set up some covariates with expand.grid
.
Specify some fixed and random parameters.
Use the makeLmer
or makeGlmer
function to
build an artificial lme4
object.
## Linear mixed model fit by REML ['lmerMod']
## Formula: y ~ x + (1 | g)
## Data: X
## REML criterion at convergence: 95.0003
## Random effects:
## Groups Name Std.Dev.
## g (Intercept) 0.7071
## Residual 1.0000
## Number of obs: 30, groups: g, 3
## Fixed Effects:
## (Intercept) x
## 2.0 -0.1
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: poisson ( log )
## Formula: z ~ x + (x | g)
## Data: X
## AIC BIC logLik deviance df.resid
## 206.3039 213.3099 -98.1520 196.3039 25
## Random effects:
## Groups Name Std.Dev. Corr
## g (Intercept) 0.7071
## x 0.3162 0.22
## Number of obs: 30, groups: g, 3
## Fixed Effects:
## (Intercept) x
## 2.0 -0.1
Now we have “pilot” models, which can be used with
simr
.
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## Power for predictor 'x', (95% confidence interval):
## 30.00% (11.89, 54.28)
##
## Test: Kenward Roger (package pbkrtest)
## Effect size for x is -0.10
##
## Based on 20 simulations, (0 warnings, 0 errors)
## alpha = 0.05, nrow = 30
##
## Time elapsed: 0 h 0 m 1 s
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## boundary (singular) fit: see help('isSingular')
## Power for predictor 'x', (95% confidence interval):
## 35.00% (15.39, 59.22)
##
## Test: z-test
## Effect size for x is -0.10
##
## Based on 20 simulations, (0 warnings, 0 errors)
## alpha = 0.05, nrow = 30
##
## Time elapsed: 0 h 0 m 2 s