report regression result using stargazer to add separate column for standard error
Asked Answered
S

1

6

I am trying to use stargazer() to export my regression result. I wanted to be able to report both coefficient and standard error in separate columns see this pic here:

enter image description here

However I can only get coefficient and standard error in the same row using single.row = TRUE. Is there something to achieve the desired result?

enter image description here

Singlehandedly answered 4/9, 2018 at 18:57 Comment(0)
R
1

How about getting all components that you need from the model output, store it as a dataframe and display this in stargazer style?

library(stargazer)
model<-lm(mpg~disp+factor(cyl), data=mtcars)
stargazer(model, type="text", omit="cyl")

results <- data.frame(Coefficient = summary(model)$coefficients[,1],
                      Standard_Error = summary(model)$coefficients[,2])

stargazer(results, title="Table 1: Results", summary=F, type = "text")

Table 1: Results
=======================================
             Coefficient Standard_Error
---------------------------------------
(Intercept)    29.535        1.427     
disp           -0.027        0.011     
factor(cyl)6   -4.786        1.650     
factor(cyl)8   -4.792        2.887     
---------------------------------------
Rectilinear answered 12/1, 2023 at 11:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.