我有一个用 构建的模型nlme::lme
,只有一个随机效应 (ID) 和一个二元自变量 (x)。我现在正在尝试使用此模型进行样本量计算。
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
R中的simr
包似乎可以完成这项工作。
但是,由于错误,我实际上没有得到任何结果,而且我不知道这里可能出了什么问题...
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
我在网上找到了一些关于将测试更改为“t”或“z”而不是“lr”的建议,但这并没有改变任何东西......
然后我跑去 lastResult()$err
看看出了什么问题,我得到了以下信息,但我找不到到底是什么......
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
我会欣赏任何形式的帮助,甚至是使用此模型进行示例计算的任何其他方式...
谢谢!