How do I get standardized beta coefficients using modelsummary in R? And how to omit more than one variable using modelsummary?

Viewed 141

I am using modelsummary to create a table. I would like to the estimate (regression coefficients) to be standardized. I used lm.beta() but the estimate = is giving me the non-standardized coefficient. Also, I would like to use coef.omitt to take out more than one variable. How might I do this?

1 Answers

This solution only works using the development version of modelsummary. This version should be on CRAN in the next few weeks, but you can install it now:

library(remotes)
install_github("vincentarelbundock/modelsummary")

Under the hood, modelsummary uses the parameters package to extract parameters from model objects. As you can see here, that package can apply several different kinds of standardization. You can pass a standardize argument directly to modelsummary(), which will then pass it down to parameters.

The coef_omit argument accepts regular expressions. See the documentation to learn how to omit several coefficients. ex: coef_omit="x|y|z"

For example:

library(modelsummary)
mod <- lm(mpg ~ hp + factor(cyl), data = mtcars)
modelsummary(mod, standardize = "basic")
Model 1
(Intercept) 0.000
(0.000)
hp -0.273
(0.175)
factor(cyl)6 -0.416
(0.114)
factor(cyl)8 -0.713
(0.195)
Num.Obs. 32
R2 0.754
R2 Adj. 0.727
AIC 169.9
BIC 177.2
F 28.585
RMSE 2.94
Related