extract_equation {LearnVizLMM}R Documentation

Model equation in 'LaTeX' format

Description

extract_equation() takes the nlme::lme() or lme4::lmer() code for fitting a linear mixed effect model and returns the corresponding model equation written in 'LaTeX' notation.

Usage

extract_equation(
  model,
  cat_vars = NULL,
  cat_vars_nlevels = NULL,
  output_type = "latex"
)

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.

output_type

Output type can be "latex" (default), "string", or "none".

Value

None (invisible NULL) (output_type = "latex"), a string (output_type = "string"), or no output (output_type = "none").

Examples

# Different ways to write the same lme model
extract_equation(model = "lme(score ~ age, random=~age|subject)")
extract_equation(model = "lme(score ~ age, random=list(subject=~age))")

# Correlated vs. Uncorrelated
extract_equation(model = "lmer(score ~ age + (age|subject))")
extract_equation(model = "lmer(score ~ age + (age||subject))")

# Add a categorical predictor and interaction
extract_equation(model = "lmer(score ~ age*treat + (age|subject))",
                 cat_vars = "treat",
                 cat_vars_nlevels = 3)

[Package LearnVizLMM version 1.0.0 Index]