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

model_identify_variables

Identify for each coefficient of a model the corresponding variable


Description

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

Usage

model_identify_variables(model)

## Default S3 method:
model_identify_variables(model)

## S3 method for class 'lavaan'
model_identify_variables(model)

## S3 method for class 'aov'
model_identify_variables(model)

## S3 method for class 'clm'
model_identify_variables(model)

## S3 method for class 'clmm'
model_identify_variables(model)

## S3 method for class 'gam'
model_identify_variables(model)

Arguments

model

a model object

Value

A tibble with four columns:

  • term: coefficients of the model

  • variable: the corresponding variable

  • var_class: class of the variable (cf. stats::.MFclass())

  • var_type: "continuous", "dichotomous" (categorical variable with 2 levels), "categorical" (categorical variable with 3 or more levels), "intercept" or "interaction"

  • var_nlevels: number of original levels for categorical 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
  ) %>%
  model_identify_variables()

iris %>%
  lm(
    Sepal.Length ~ poly(Sepal.Width, 2) + Species,
    data = .,
    contrasts = list(Species = contr.sum)
  ) %>%
  model_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.