[英]different random effects in nlme and lme4
I fit this model in nlme
: 我在
nlme
适合这个模型:
library(nlme)
data("Machines")
fit1 <- lme(score ~ - 1 + Machine, random=~1|Worker, data=Machines)
I can get the coefficients with 我可以得到系数
> fit1$coefficients
$fixed
MachineA MachineB MachineC
52.35556 60.32222 66.27222
$random
$random$Worker
(Intercept)
6 -8.70711058
2 -1.59425968
4 -0.06931564
1 1.21035769
3 6.21174760
5 2.94858062
now I fit the same model in lme4
现在我在
lme4
使用相同的型号
library(lme4)
fit2 <- lmer(score ~ -1 + Machine + (1|Worker), data=Machines)
I get the exact same fixed effects: 我得到完全相同的固定效果:
>summary(fit2)
...
Fixed effects:
Estimate Std. Error t value
MachineA 52.356 2.229 23.48
MachineB 60.322 2.229 27.06
MachineC 66.272 2.229 29.73
...
I now want the random effects per worker, they aren't displayed in the summary, but it must be this: 我现在想要每个工人的随机效果,它们不会显示在摘要中,但必须是这样的:
> fit2@u
[1] -5.34898187 -0.97939105 -0.04258222 0.74355106 3.81602197 1.81138210
why are they different from the nlme
results while the fixed effects are the same? 为什么它们与
nlme
结果不同而固定效果相同?
Use ranef()
to extract the random effects. 使用
ranef()
来提取随机效果。
library(lme4)
library(nlme)
data("Machines")
fit1 <- lme(score ~ - 1 + Machine, random=~1|Worker, data=Machines)
ranef(fit1)
fit2 <- lmer(score ~ -1 + Machine + (1|Worker), data=Machines)
ranef(fit2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.