[英]Plotting an interaction with confidence intervals from an lme4 or LmerTest model in R
使用dat
(在此处找到),我运行以下 model:
library(lmerTest)
model <- lmerTest::lmer(eval ~ post + ess + post*ess + (1|ID), data = dat)
summary(model)
的 output 表示交互项显着:
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: eval ~ post + ess + ess * post + (1 | ID)
Data: dat
REML criterion at convergence: 163.4
Scaled residuals:
Min 1Q Median 3Q Max
-1.95714 -0.48596 0.00623 0.49208 1.82729
Random effects:
Groups Name Variance Std.Dev.
ID (Intercept) 0.33344 0.5774
Residual 0.02944 0.1716
Number of obs: 170, groups: ID, 85
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 1.50194 0.09082 90.00645 16.538 < 0.0000000000000002 ***
post -0.24537 0.03658 83.00000 -6.707 0.00000000226 ***
ess 0.15444 0.13076 90.00645 1.181 0.24067
post:ess 0.15620 0.05267 83.00000 2.965 0.00395 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) post ess
post -0.201
ess -0.695 0.140
post:ess 0.140 -0.695 -0.201
但是,当我尝试使用sjPlot
使用 95% 置信区间 plot 进行交互时,得到的区间不会使交互看起来很重要......
library(sjPlot)
library(TMB)
plot_model(model, type="int", ci.lvl=0.95)
我的两个问题:
plot_model()
? 我想制作一个条形 plot 来说明交互,因为变量ess
和post
是二进制的。 注意:我很高兴使用lme4
- 应该得到相同的结果,当总结 lme4 对象时,什么系数很重要并不那么明显,我希望这个问题非常清楚。
我将按相反的顺序回答您的问题:
plot_model()
function 调用来自ggeffects
package 的函数。 具体来说, ggpredict()
做了很多工作。 如果你从 go 到下面的 URL,你会发现很多关于如何改变效果图和从拟合的 model 中获取各种信息的信息。https://cran.r-project.org/web/packages/ggeffects/vignettes/ggeffects.html
sjPlot
的默认行为。 我已经安装了您指定的 model 和因子,并按照我认为应该在下面绘制的方式绘制了它。 我认为 plot 的变化不大,但它可能会改变你的解释。 plot 此处显示的差异与 model 总结ess
一致,可以这样表述:差异是 1 的 0 与 1 的 CI 的两个级别之间post
差异。当post
为 0 时,这两个ess
类别与均值重叠,但当post
为 1 时它们显着不同。让我知道这是否需要进一步澄清。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.