How to use update () for random part in lmer ()?

I would like to use the function update()to update a random part of my model, in particular, to add a random effect. Most of the examples ( help("update"), help("update.formula"), lme4: mixed effects modeling R ) centered on a fixed part of the model. How do I go from fm0to fm1using update()in the example below?

library(lme4)
(fm0 <- lmer(Reaction ~ Days + (1 | Subject), sleepstudy))
(fm1 <- lmer(Reaction ~ Days + (1 + Days | Subject), sleepstudy))
+4
source share
1 answer

I doubt it will be useful in your case, but you need to remove the random effect, and then add the desired back:

update(fm0, . ~ . -(1|Subject) + (1 + Days | Subject))
+4
source

Source: https://habr.com/ru/post/1681776/


All Articles