且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换R中的Lmer系数

更新时间:2023-02-18 11:28:59

我看不到这样做的正当理由,您可能会遇到一些强大的巨龙,但这样做很容易.

I don't see a valid reason to do this and you might encounter some mighty dragons, but it is easy to do.

library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
summary(fm1)$coef
#             Estimate Std. Error   t value
#(Intercept) 251.40510   6.823773 36.842535
#Days         10.46729   1.545958  6.770744

fm1@beta[names(fixef(fm1)) == "Days"] <- 0
summary(fm1)$coef
#            Estimate Std. Error  t value
#(Intercept) 251.4051   6.823773 36.84253
#Days          0.0000   1.545958  0.00000