如何在R中使用LMER提取多级建模中的随机效果?
例如,这是某些多级分析
MLM1< -lmer(Y〜1 + CON + CON + EV1 + EV2 +(1 | PID),data = dat_ind)
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: y ~ 1 + con + ev1 + ev2 + (1 | pid)
Data: dat_ind
REML criterion at convergence: 837
Scaled residuals:
Min 1Q Median 3Q Max
-2.57771 -0.52765 0.00076 0.54715 2.27597
Random effects:
Groups Name Variance Std.Dev.
pid (Intercept) 1.4119 1.1882
Residual 0.9405 0.9698
Number of obs: 240, groups: pid, 120
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 0.1727 0.1385 116.7062 1.247 0.21494
con 0.3462 0.1044 227.3108 3.317 0.00106 **
ev1 -0.3439 0.2083 116.8432 -1.651 0.10143
ev2 0.2525 0.1688 117.0168 1.495 0.13753
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) con ev1
con 0.031
ev1 0.171 -0.049
ev2 -0.423 0.065 -0.407
的结果,例如,我可以提取固定效果,例如以下效果。 摘要(MLM1)[['系数']] ['ev1','pr(> | t |)']
如何提取随机效应系数? 例如,我想提取1.4119、1.1882、0.9405、0.9698。
随机效果: 组名称差异std.dev。 PID(截距)1.4119 1.1882
残留0.9405 0.9698
For example, this is the result of certain multilevel analysis
MLM1<-lmer(y ~ 1 + con + ev1 + ev2 + (1 | pid),data=dat_ind)
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: y ~ 1 + con + ev1 + ev2 + (1 | pid)
Data: dat_ind
REML criterion at convergence: 837
Scaled residuals:
Min 1Q Median 3Q Max
-2.57771 -0.52765 0.00076 0.54715 2.27597
Random effects:
Groups Name Variance Std.Dev.
pid (Intercept) 1.4119 1.1882
Residual 0.9405 0.9698
Number of obs: 240, groups: pid, 120
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 0.1727 0.1385 116.7062 1.247 0.21494
con 0.3462 0.1044 227.3108 3.317 0.00106 **
ev1 -0.3439 0.2083 116.8432 -1.651 0.10143
ev2 0.2525 0.1688 117.0168 1.495 0.13753
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) con ev1
con 0.031
ev1 0.171 -0.049
ev2 -0.423 0.065 -0.407
for example, I can extract fixed effect such as following.
summary(MLM1)[['coefficients']]['ev1','Pr(>|t|)']
How can I extract random effect coefficients?
for example, I want to extract 1.4119, 1.1882, 0.9405, 0.9698.
Random effects:
Groups Name Variance Std.Dev.
pid (Intercept) 1.4119 1.1882
Residual 0.9405 0.9698
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
VARCORR(MLM1)$ PID
是基本对象。broom.mixed :: tidy(mlm1,效果=“ ran_pars”)
可能会给您更方便的格式。或者:
VarCorr(MLM1)$pid
is the basic object.broom.mixed::tidy(MLM1, effects = "ran_pars")
may give you a more convenient format.Or:
随机效应结果不是系数,而是摘要输出中报告的差异和标准偏差,您可以使用
varcorr
函数。例如,
如果您希望结果作为表:
显然,您需要
pid
而不是上面的代码中的主题
- 我们没有您的在此处进行演示的数据或模型。由
The random effects results are not coefficients, but to get the variance and standard deviation as reported in the summary output, you can use the
VarCorr
function.For example,
If you want the results as a table you could do:
Obviously, you'll need
pid
instead ofSubject
in the code above - we don't have your data or model for a demo here.Created on 2022-04-27 by the reprex package (v2.0.1)