Home > front end >  How to report standardized coefficients in stargazer package?
How to report standardized coefficients in stargazer package?

Time:04-20

I have just started using the stargazer package in R to automate the creation of tables. I expected that if I create a simple regression model and I feed that into the stargazer package, I should expect to observe the coefficients from the model and the p-values that I obtain from the summary() function.

mod = lm(mtcars$mpg~mtcars$cyl mtcars$disp)
summary(mod)

Produces:

enter image description here

And then feeding this into stargazer:

stargazer(mod,p.auto = FALSE, 
          align=TRUE, no.space = TRUE, out = "./mtcars.htm", type = 'html')

Produces:

enter image description here

This looks fine. However, what I want is to instead report the standardized coefficients instead of the non-standardized ones. I have used this function "lm.beta" to achieve this:

mod_std = lm.beta(mod)
stargazer(mod_std,p.auto = FALSE, 
          align=TRUE, no.space = TRUE, out = "./mtcars.htm", type = 'html')

Hoping that now stargazer will use the standardized coefficients. The output I get is:

enter image description here

This is strange, because it looks like the significance level changed. Which should not be the case. And still, the unstandardized coefficients are reported. Any ideas on how I could make the package report the standardized coefficients instead?

CodePudding user response:

I think your question has already been answered here: Including standardized coefficients in a stargazer table

Stargazer does not automatically know it should look for the standardized coefficients in the second model. lm.beta just add standardzied coefficients to the lm.object. So it is still an lm.object, so it extracts the coefficients as per usual (from model1.beta$coefficients. Use the coef = argument to specify the specific coefficients you want to use: coef = list(mod_std$coefficients, mod_std.beta$standardized.coefficients)

stargazer(mod_std, mod_std.beta, 
            coef = list(mod_std$coefficients, 
            mod_std.beta$standardized.coefficients),
            type='text')
  • Related