extract_glm: Extract a custom texreg object from a glm() model

View source: R/GLM_functions.R

extract_glmR Documentation

Extract a custom texreg object from a glm() model

Description

Extracts a custom texreg object from a glm() model via broom::tidy() and broom::glance(), adding more goodness of fit statistics along the way.

Usage

extract_glm(model, digits = 2)

Arguments

model

A logistic regression model fit via glm(family = binomial).

digits

An integer specifying the number of decimal places to used when rounding the result. Defaults to NULL, which does not round the result.

Details

=============================================================================

This function facilitate using [texreg::texreg()] to create tables summarizing logistic regression models that contain all the default goodness of fit statistics supplied by [broom::glance()], plus additional fit statistics generated by the piercer package functions [brier()], [pseudoR2()], and [R2Dev()]. The code was adapted from an online answer posted at https://stackoverflow.com/a/52037395.

Value

A texreg object for the model.

References

Cameron, A. C., & Windmeijer, F. A. G. (1997). An R-squared measure of goodness of fit for some common nonlinear regression models. Journal of Econometrics, 77(2), 329-342. doi:10.1016/S0304-4076(96)01818-0

Fox, J. (1997). Applied regression analysis, linear models, and related methods. Thousand Oaks, CA: Sage Publications.

Hosmer, D. W., Lemeshow, S., & Sturdivant, R. X. (2013). Applied logistic regression (3rd ed.). Hoboken, NJ: John Wiley & Sons, Inc.

See Also

See [brier()] for Brier scores, [pseudoR2()] for pseudo-R^2, [R2Dev()] for R^2 based on deviance. See [broom::tidy()] and [broom::glance()] for details about using the broom package to extract tidy summaries of models, and [texreg::texreg()] for details about using the texreg package to build tables summarizing regression models.

Examples

m1 <- glm(formula = vs ~ wt + disp, family = binomial, data = mtcars)
extract_glm(m1)
extract_glm(m1, digits = 3)


sjpierce/piercer documentation built on Dec. 30, 2024, 3:28 p.m.