Runs either a linear regression, logistic regression, or multinomial classification. The model is automatically determined based off the nature of the target variable.
tidy_glm(data, formula)
dataframe
formula
glm model
# linear regression
iris %>%
tidy_glm(
tidy_formula(., target = Petal.Width)) -> glm1
glm1
#>
#> Call: stats::glm(formula = formula, family = glm_family, data = data)
#>
#> Coefficients:
#> (Intercept) Sepal.Length Sepal.Width Petal.Length
#> -0.47314 -0.09293 0.24220 0.24220
#> Speciesversicolor Speciesvirginica
#> 0.64811 1.04637
#>
#> Degrees of Freedom: 149 Total (i.e. Null); 144 Residual
#> Null Deviance: 86.57
#> Residual Deviance: 3.998 AIC: -104.1
glm1 %>%
visualize_model()
# multinomial classification
tidy_formula(iris, target = Species) -> species_form
iris %>%
tidy_glm(species_form) -> glm2
glm2 %>%
visualize_model()
# logistic regression
iris %>%
dplyr::filter(Species != "setosa") %>%
tidy_glm(species_form) -> glm3
suppressWarnings({
glm3 %>%
visualize_model()})