R 中 SPSS 的简单对比输出

问题描述 投票:0回答:1

我用SPSS中的GENLINMIXED命令估计了一个混合模型。在模型选项中,我指定要通过变量“组”估计交互变量(类别*组)的简单对比。 “简单对比”的输出如下所示:enter image description here

我希望在 R 中获得相同的输出,其中我使用

glmer
包中的
lme4
估计模型。有谁知道该怎么做吗?

r spss contrast
1个回答
0
投票

一般来说,您会使用

emmeans
包来实现此目的。 这是一个使用
lm()
和内置数据集的示例:它应该同样适用于
glmer
模型,在
~group | category
语句中替换
emmeans()
并在
ref="0"
 (或类似的东西)中替换contrast()
声明。

library(emmeans)
warp.lm <- lm(breaks ~ wool*tension, data = warpbreaks)
warp.emm <- emmeans(warp.lm, ~ tension | wool))
cc <- contrast(warp.emm, "trt.vs.ctrl", ref = "S")
summary(cc, infer = TRUE, adjust = "none")
wool = A:
 contrast estimate   SE df lower.CL upper.CL t.ratio p.value
 M - L     -20.556 5.16 48   -30.93  -10.186  -3.986  0.0002
 H - L     -20.000 5.16 48   -30.37   -9.631  -3.878  0.0003

wool = B:
 contrast estimate   SE df lower.CL upper.CL t.ratio p.value
 M - L       0.556 5.16 48    -9.81   10.925   0.108  0.9147
 H - L      -9.444 5.16 48   -19.81    0.925  -1.831  0.0733
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.