我注意到,当我比较固定效应模型和混合效应模型的结果时,我得到的(固定效应)协变量斜率的标准误差非常相似,而在截距上,固定效应模型的标准误差要小得多(而参数估计本身几乎相同)。为什么是这样?
例子
例如,我得到了这些结果(此处删节;底部有完整结果):
Mixed Model
Estimate Std. Error t value
(Intercept) 21.040772 1.921112 10.95
x -1.007014 0.009933 -101.38
Fixed Effects Model
Estimate Std. Error t value Pr(>|t|)
(Intercept) 21.043157 0.055888 376.52 <2e-16 ***
x -1.007443 0.009934 -101.41 <2e-16 ***
对于看起来像这样的数据(不同级别的不同符号p
):
从这段代码:
set.seed(1)
generatepoint = function(ppt,n){
x = rnorm(n)+ppt
y = -x + 10 + 2*ppt + rnorm(n,sd=.1)
cbind(x=x,y=y,p=ppt)
}
data = as.data.frame(do.call(rbind,lapply(1:10,generatepoint,10)))
plot(y~x,data=data,pch=data$p)
data$p = factor(data$p)
cat("\n\nMixed Model\n\n")
mod = lmer(y~x+(1|p),data=data)
print(summary(mod))
cat("\n\nFixed Model\n\n")
contrasts(data$p) <- contr.sum(10)
fmod = lm(y~x+p,data=data)
print(summary(fmod))
这是完整的输出:
Mixed Model
Linear mixed model fit by REML ['lmerMod']
Formula: y ~ x + (1 | p)
Data: data
REML criterion at convergence: -88.6
Scaled residuals:
Min 1Q Median 3Q Max
-2.6303 -0.6669 -0.1463 0.6713 2.2773
Random effects:
Groups Name Variance Std.Dev.
p (Intercept) 36.87548 6.07252
Residual 0.00807 0.08983
Number of obs: 100, groups: p, 10
Fixed effects:
Estimate Std. Error t value
(Intercept) 21.040772 1.921112 10.95
x -1.007014 0.009933 -101.38
Correlation of Fixed Effects:
(Intr)
x -0.029
Fixed Model
Call:
lm(formula = y ~ x + p, data = data)
Residuals:
Min 1Q Median 3Q Max
-0.23547 -0.06006 -0.01333 0.06017 0.20400
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 21.043157 0.055888 376.52 <2e-16 ***
x -1.007443 0.009934 -101.41 <2e-16 ***
p1 -9.009845 0.051524 -174.87 <2e-16 ***
p2 -7.017192 0.045469 -154.33 <2e-16 ***
p3 -5.005483 0.036105 -138.64 <2e-16 ***
p4 -3.034799 0.029087 -104.34 <2e-16 ***
p5 -0.993759 0.027279 -36.43 <2e-16 ***
p6 0.992106 0.028082 35.33 <2e-16 ***
p7 2.966062 0.030515 97.20 <2e-16 ***
p8 4.987105 0.032854 151.79 <2e-16 ***
p9 7.100627 0.045236 156.97 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.08983 on 89 degrees of freedom
Multiple R-squared: 0.9993, Adjusted R-squared: 0.9992
F-statistic: 1.194e+04 on 10 and 89 DF, p-value: < 2.2e-16