extract_variables {LearnVizLMM}R Documentation

Roles of variables

Description

extract_variables() returns a data frame of information of the variables in a nlme::lme() or lme4::lmer() model. The columns of the data frame include: Effect (whether the effect is random or fixed), Group (group or grouping factor associated with random effects), Term (notation used to include the variable in the model), Description (description of the Term), and Parameter (parameter estimated when the model is fit).

Usage

extract_variables(model, cat_vars = NULL, cat_vars_nlevels = NULL)

Arguments

model

Code for fitting a nlme::lme() or lme4::lmer() model given as a string.

cat_vars

Optional character vector of the names of categorical predictor variables included in the model. Default is NULL, which assumes that all predictor variables are numeric.

cat_vars_nlevels

Optional numeric vector of the number of levels (i.e. categories) for each variable in cat_vars. Must be a vector of same length as cat_vars. Values must be whole numbers greater than 1 and less than 10. Only applies if cat_vars is not NULL.

Value

A data frame.

Examples

# lme()
extract_variables(model = "lme(Score~type,random=list(School=pdDiag(~1+type),Class=~1))",
                  cat_vars = "type",
                  cat_vars_nlevels = 2)
extract_variables(model = "lme(weight~1+Time+I(Time^2),random=~Time+I(Time^2)|ID)")

# lmer()
extract_variables(model = "lmer(Strength ~ 1 + (1|Machine) + (1|Worker))")
extract_variables(model = "lmer(score ~ age*treat + (age|subject))",
                  cat_vars = "treat",
                  cat_vars_nlevels = 3)

[Package LearnVizLMM version 1.0.0 Index]