使用powerSim进行多水平模型功效分析时遇新水平检测错误
多水平模型powerSim功效估计报错问题
所有变量(因变量DV、自变量IV)均为连续变量,使用powerSim对多水平模型做功效估计时,400次模拟全部报错,模型功效显示为0.00%,错误提示为在newdata中检测到新水平:120、125、336、347。
代码实现
# 示例数据 # 定义多水平模型: m1 <- lmer(a_p2relsat ~ (Avoidance_centering + Anxiety_centering) * Identification_centering + (1|ID), control = lmerControl(optimizer = "bobyqa"), data = S2) # 修改交互项Avoidance_centering:Identification_centering的效应量为0.2: model_size <- m1 fixef(model_size)['Avoidance_centering:Identification_centering'] <- 0.2 # 执行功效分析: power_m1 <- powerSim(model_size, test=fcompare(a_p2relsat~Avoidance_centering:Identification_centering), nsim=400) power_m1
功效分析输出结果
> power_m1 Power for model comparison, (95% confidence interval): 0.00% ( 0.00, 0.92) Test: Likelihood ratio Comparison to a_p2relsat ~ Avoidance_centering:Identification_centering + [re] Based on 400 simulations, (0 warnings, 400 errors) alpha = 0.05, nrow = NA Time elapsed: 0 h 0 m 5 s
错误详情
> lastResult()$errors stage index message 1 Simulating 1 new levels detected in newdata: 120, 125, 336, 347 2 Simulating 2 new levels detected in newdata: 120, 125, 336, 347 3 Simulating 3 new levels detected in newdata: 120, 125, 336, 347 4 Simulating 4 new levels detected in newdata: 120, 125, 336, 347 5 Simulating 5 new levels detected in newdata: 120, 125, 336, 347 6 Simulating 6 new levels detected in newdata: 120, 125, 336, 347 7 Simulating 7 new levels detected in newdata: 120, 125, 336, 347 8 Simulating 8 new levels detected in newdata: 120, 125, 336, 347 9 Simulating 9 new levels detected in newdata: 120, 125, 336, 347 10 Simulating 10 new levels detected in newdata: 120, 125, 336, 347
内容的提问来源于stack exchange,提问作者梁琦奇
相关产品推荐
相关产品推荐

