Suppose we have postulated the following linear mixed model (LMM), which we generically call fit.
library(lme4)
fit <- lmer(Reaction ~ Days + (1 | Subject), data = sleepstudy)
Suppose that we are also interested in extracting the original formula (i.e. both the fixed-effects and random-effects part) from fit, which we would like to pass to a second LMM termed fit2. Obviously, passing terms(fit) to the formula argument of lmer() does not work.
> fit2 <- lmer(terms(fit), data = sleepstudy)
Error: No random effects terms specified in formula
Question
Is there a way to extract both fixed-effects and random-effects part from fit, which can then be passed to lmer()?