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>:
Hello, I can extract the name(s) of random intercept variable(s) with this command:
names(VarCorr(model))
Is there any easy way to extract the names of random slope variables? I can't find it anywhere in str(model). Thanks a lot, Dan P.S. I know I could compare the list of all variables, e.g.
names(model.frame(model))
with the headings inside e.g. ranef(model), and match it up that way, but I was wondering if there was anything easier. Also, I can't use model at call because I'm calling lmer() out of another function! [[alternative HTML version deleted]]
_______________________________________________ R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Sven Hohenstein Department of Psychology University of Potsdam Karl-Liebknecht-Str. 24-25 14476 Potsdam Germany Tel.: ++49 331-977 2370