简体   繁体   English

"lmer 输出的方差分量的标准误差"

[英]Standard Error of variance component from the output of lmer

I need to extract the standard error<\/code> of variance component from the output of lmer<\/code> .我需要从lmer<\/code>的输出中提取方差分量的standard error<\/code> 。

library(lme4)
model <- lmer(Reaction ~ Days + (1|Subject), sleepstudy)

I think you are looking for the Wald standard error of the variance estimates.我认为您正在寻找方差估计的 Wald 标准误差。 Please note that these (as often pointed out by Doug Bates) the Wald standard errors are often very poor<\/strong> estimates of the uncertainty of variances, because the likelihood profiles are often far from quadratic on the variance scale ... I'm assuming you know what you're doing and have some good use for these numbers ...请注意,这些(正如 Doug Bates 经常指出的那样)Wald 标准误差通常是对方差不确定性的非常差<\/strong>的估计,因为似然分布通常远离方差尺度上的二次方......我假设你知道你在做什么并且对这些数字有一些好处......

This can be (now) done using the merDeriv<\/code> package.这可以(现在)使用merDeriv<\/code>包完成。

library(lme4)
library(merDeriv)
m1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
sqrt(diag(vcov(m1, full = TRUE)))
vv <- vcov(m1, full = TRUE)
colnames(vv)
## [1] "(Intercept)"                  "Days"                        
## [3] "cov_Subject.(Intercept)"      "cov_Subject.Days.(Intercept)"
## [5] "cov_Subject.Days"             "residual"

I'm not really sure what you mean by "standard error of variance component".我不太确定“方差分量的标准误差”是什么意思。 My best guess (based on your code) is that you want the standard error of the random effect.我最好的猜测(根据您的代码)是您想要随机效应的标准误差。 You can get this using package arm:您可以使用包 arm 获得此信息:

library(arm)
se.ranef(model)
#$Subject
#    (Intercept)
#308    9.475668
#309    9.475668
#310    9.475668
#330    9.475668
#331    9.475668
#332    9.475668
#333    9.475668
#334    9.475668
#335    9.475668
#337    9.475668
#349    9.475668
#350    9.475668
#351    9.475668
#352    9.475668
#369    9.475668
#370    9.475668
#371    9.475668
#372    9.475668
mn2=lmer(pun~ pre + (pre|pro), REML = TRUE, data = pro)
summary(mn2)
coe2=coef(mn2)
coe2

# Matriz de varianza-covarianza (covarianza)
as.data.frame(VarCorr(mn2))

# Extraer coeficientes fijos
fixef(mn2)

# Extraer desvios de a - alfa y b - beta
re=as.data.frame(ranef(mn2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM