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

使用R包simr进行混合效应模型功效分析时遭遇‘object is not a matrix’错误的技术求助

混合效应模型功效分析(simr包)求助

我构建了如下混合效应模型:

ModelPower <- lmer(DV ~ GroupAbstract * Condition_Cat_Abs + (1|Participant) + (1 + GroupAbstract|Stimulus), data = Dataset)

模型输出结果

随机效应:

GroupsNameVarianceStd.Dev.Corr
Participant(Intercept)377.40119.427
Stimulus(Intercept)91.9029.587
StimulusGroupAbstractOutgroup2.0031.415-0.40
Residual338.92718.410

观测数:16512,分组:Participant(344组);Stimulus(32组)

固定效应:

TermEstimateStd. Errordft valuePr(>t)
(Intercept)65.89622.023959.690632.559< 0.0000000000000002 ***
GroupAbstractOutgroup-0.92870.5561129.9242-1.6700.0973 .
Condition_Cat_AbsSecondOrderIn-2.25840.496316103.9277-4.5500.00000539 ***
Condition_Cat_AbsSecondOrderOut-7.08210.496316103.9277-14.270< 0.0000000000000002 ***
GroupAbstractOutgroup:Condition_Cat_AbsSecondOrderIn-3.02290.701916103.9277-4.3070.00001665 ***
GroupAbstractOutgroup:Condition_Cat_AbsSecondOrderOut7.87650.701916103.927711.222< 0.0000000000000002 ***

问题描述

我重点关注交互项GroupAbstractOutgroup:Condition_Cat_AbsSecondOrderIn,想使用simr包估计能检测到至少**-2效应量**的样本量。原模型中该交互项的斜率是-3.02,所以我用下面的代码修改了模型参数:

ModelPower@beta[names(fixef(ModelPower)) %in% "GroupAbstractOutgroup:Condition_Cat_AbsSecondOrderIn"] <- -2

但不管怎么设置powerSim函数(示例如下),得到的功效始终是0%。而且运行lastResult()$errors时,会出现错误提示:object is not a matrix。我理解这个错误的字面意思,但就算把原始数据框和固定效应表都转换成矩阵,错误还是存在。我搞不清这个错误到底指向哪个对象,也没法得到有效的功效分析结果,恳请大家帮忙解决!

尝试过的powerSim调用示例

powerSim(ModelPower, test=fixed("GroupAbstract", "anova"), nsim=10, seed=1)
powerSim(ModelPower, test=fixed("GroupAbstractOutgroup:Condition_Cat_AbsSecondOrderIn", "anova"), nsim=10, seed=1)

内容的提问来源于stack exchange,提问作者Joseph K.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 18:08:10