Skip to content
Prev 10400 / 20628 Next

extracting name of random slope from mer object

Hi Dan,

you can use the following approach to extract the names of  
random-slope variables:

# the model terms
term <- terms(model)
# all variables
vars <- as.character(attr(terms, "predvars")[-1])
# fixed variables
varsFix <- as.character(attr(terms, "predvars.fixed")[-1])
# random factors
varsRan <- names(ranef(model))

# Now, the names of the fixed variables and the random factors
# can be removed from the vector including all variable names:
Reduce(setdiff, list(vars, varsFix, varsRan))


This approach works with lme4 version 0.99999911-7. It might not work  
with models created with earlier versions of lme4.

Best,
Sven





Quoting Daniel Ezra Johnson <danielezrajohnson at gmail.com>: