I am trying to extract a random structure from models built with lme, but I cannot get anything but a fixed formula. For instance.
library(nlme)
fm1 <- lme(distance ~ age, Orthodont, random = ~ age | Subject)
deparse(terms(fm1))
# "distance ~ age"
This is possible lmerwith findbars():
library(lmerTest)
fm2 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
findbars(formula(fm2))
I want to be able to extract:
I could use this with help regexpr, but I would also like it to apply to more complex structures (multiple random slopes, nested random variables, etc.) and which may include additive or random slopes. Thank!
source
share