替换R中的Lmer系数 [英] Replace lmer coefficients in R
本文介绍了替换R中的Lmer系数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的帖子中,
我也对改变装有lmer的混合模型的系数感兴趣.例如在以下形式的模型中:
I am also interested in changing the coefficients of a mixed model fitted with lmer. For e.g. in a a model of the form below:
mod <- lmer(y ~ x1 + x2 + x3 + (1|class/subjects), data=data)
如何将x1和x2的系数更改为另一个数字(0或0.1或1等).
How can I change the coefficients of x1 and x2 to another number (0 or 0.1 or 1 etc).
推荐答案
我看不到这样做的正当理由,您可能会遇到一些强大的巨龙,但这样做很容易.
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
这篇关于替换R中的Lmer系数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文