从lme4 mer模型对象中提取随机效应方差 [英] Extract random effect variances from lme4 mer model object

查看:136
本文介绍了从lme4 mer模型对象中提取随机效应方差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有固定和随机作用的mer对象.如何提取随机效应的方差估计值?这是我的问题的简化版本.

I have a mer object that has fixed and random effects. How do I extract the variance estimates for the random effects? Here is a simplified version of my question.

study <- lmer(Reaction ~ Days + (1|Subject), data = sleepstudy)
study

这将提供长输出-在这种情况下,不会太长.无论如何,我如何明确选择

This gives a long output - not too long in this case. Anyway, how do I explicitly select the

Random effects:
Groups   Name        Variance Std.Dev.
Subject  (Intercept) 1378.18  37.124  
Residual              960.46  30.991  

部分输出?我想要值本身.

part of the output? I want the values themselves.

我看了很久

str(study)

那里什么都没有!还检查了lme4软件包中的所有提取器功能,均无济于事.请帮忙!

and there's nothing there! Also checked any extractor functions in the lme4 package to no avail. Please help!

推荐答案

lmer返回一个S4对象,因此应该可以:

lmer returns an S4 object, so this should work:

remat <- summary(study)@REmat
print(remat, quote=FALSE)

哪些印刷品:

 Groups   Name        Variance Std.Dev.
 Subject  (Intercept) 1378.18  37.124  
 Residual              960.46  30.991  

...通常,您可以查看"mer"对象的printsummary方法的来源:

...In general, you can look at the source of the print and summary methods for "mer" objects:

class(study) # mer
selectMethod("print", "mer")
selectMethod("summary", "mer")

这篇关于从lme4 mer模型对象中提取随机效应方差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆