View source: R/GLM_functions.R
extract_glm | R Documentation |
Extracts a custom texreg object from a glm() model via broom::tidy() and broom::glance(), adding more goodness of fit statistics along the way.
extract_glm(model, digits = 2)
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. |
=============================================================================
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.
A texreg object for the model.
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 [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.
m1 <- glm(formula = vs ~ wt + disp, family = binomial, data = mtcars)
extract_glm(m1)
extract_glm(m1, digits = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.