Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tidy_identify_variables

Identify the variable corresponding to each model coefficient


Description

tidy_identify_variables() will add to the tidy tibble three additional columns: variable, var_class, var_type and var_nlevels.

Usage

tidy_identify_variables(x, model = tidy_get_model(x), quiet = FALSE)

Arguments

x

a tidy tibble

model

the corresponding model, if not attached to x

quiet

logical argument whether broom.helpers should not return a message when requested output cannot be generated. Default is FALSE

Details

It will also identify interaction terms and intercept(s).

var_type could be:

  • "continuous",

  • "dichotomous" (categorical variable with 2 levels),

  • "categorical" (categorical variable with 3 levels or more),

  • "intercept"

  • "interaction"

  • "ran_pars (random-effect parameters for mixed models)

  • "ran_vals" (random-effect values for mixed models)

  • "unknown" in the rare cases where tidy_identify_variables() will fail to identify the list of variables

For dichotomous and categorical variables, var_nlevels corresponds to the number of original levels in the corresponding variables.

See Also

Examples

Titanic %>%
  dplyr::as_tibble() %>%
  dplyr::mutate(Survived = factor(Survived, c("No", "Yes"))) %>%
  glm(Survived ~ Class + Age * Sex, data = ., weights = .$n, family = binomial) %>%
  tidy_and_attach() %>%
  tidy_identify_variables()

lm(
  Sepal.Length ~ poly(Sepal.Width, 2) + Species,
  data = iris,
  contrasts = list(Species = contr.sum)
) %>%
  tidy_and_attach(conf.int = TRUE) %>%
  tidy_identify_variables()

broom.helpers

Helpers for Model Coefficients Tibbles

v1.3.0
GPL-3
Authors
Joseph Larmarange [aut, cre] (<https://orcid.org/0000-0001-7097-700X>), Daniel D. Sjoberg [aut] (<https://orcid.org/0000-0003-0862-2018>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.