broom.helpers (version 1.0.0)

model_list_terms_levels: List levels of categorical terms

Description

Only for categorical variables with treatment, SAS or sum contrasts.

Usage

model_list_terms_levels(model)

# S3 method for default model_list_terms_levels(model)

Arguments

model

a model object

Value

A tibble with four columns:

  • variable: variable

  • term: term name

  • level: term level

  • reference: logical indicating which term is the reference level

See Also

Other model_helpers: model_get_contrasts(), model_get_model_frame(), model_get_model_matrix(), model_get_xlevels(), model_identify_variables(), model_list_contrasts(), model_list_variables()

Examples

Run this code
# NOT RUN {
glm(
  am ~ mpg + factor(cyl),
  data = mtcars,
  family = binomial,
  contrasts = list(`factor(cyl)` = contr.sum)
) %>%
  model_list_terms_levels()

df <- Titanic %>%
  dplyr::as_tibble() %>%
  dplyr::mutate(Survived = factor(Survived, c("No", "Yes")))

df %>%
  glm(
    Survived ~ Class + Age + Sex,
    data = ., weights = .$n, family = binomial,
    contrasts = list(Age = contr.sum, Class = "contr.helmert")
  ) %>%
  model_list_terms_levels()
# }

Run the code above in your browser using DataLab