I am having a model built with nlme::lme
, with only one random effect (ID) and one binary independent variable (x). I am now trying to use this model to do a sample size calculation.
Linear mixed-effects model fit by REML
Data: mydata2
AIC BIC logLik
214.0042 226.7538 -103.0021
Random effects:
Formula: ~1 | ID
(Intercept) Residual
StdDev: 0.4687304 0.2979965
Fixed effects: y ~ x
Value Std.Error DF t-value p-value
(Intercept) 2.5223996 0.08830079 111 28.565991 0.0000
x -0.0357012 0.12447286 68 -0.286819 0.7751
The simr
package in R seems to do the job.
However, i get no results actually, because of errors and i have no idea what might be wrong here...
powerSim(model1, fixed("x", "lr"), nsim = 1000)
Power for predictor 'x', (95% confidence interval):=============================|
0.00% ( 0.00, 3.62)
Test: Likelihood ratio
Based on 1000 simulations, (0 warnings, 1000 errors)
alpha = 0.05, nrow = 2
Time elapsed: 0 h 0 m 20 s
nb: result might be an observed power calculation
I found online some suggestions on changing the test to "t" or "z" instead of "lr", but this didn't change anything at all...
Then i run lastResult()$err
to see what's wrong and i get the following, which i couldn't find what is exactly...
stage index message
1 Fitting 1 invalid type/length (symbol/0) in vector allocation
2 Fitting 2 invalid type/length (symbol/0) in vector allocation
3 Fitting 3 invalid type/length (symbol/0) in vector allocation
4 Fitting 4 invalid type/length (symbol/0) in vector allocation
5 Fitting 5 invalid type/length (symbol/0) in vector allocation
I would appreaciate any kind of help, or even any other way to use this model to do a sample calculation...
Thanks!