You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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,提问作者梁琦奇

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 16:05:11