1
votes

I want to output a regression table with the covariates along the top, not down the side. This is rare, but not unheard of. See, for example, this table from Baldwin & Taglioni (2006):

enter image description here

It looks from the docs, p.6 as if this is only possible with summary tables, not with regression outputs.

With regression outputs, flip=TRUE does nothing:

> model <- lm('mpg ~ cyl + disp + drat + wt', data=mtcars)
> stargazer(model, type='text', flip=TRUE)
===============================================
                        Dependent variable:    
                    ---------------------------
                                NA             
-----------------------------------------------
cyl                          -1.786***         
                              (0.635)          
disp                           0.007           
 .                               .
 .                               .
 .                               .

I'd like to see something like this:

 cyl        disp      drat      wt
-1.786***   0.007    -0.010   -3.638***         
(0.635)    (0.012)   (1.338)  (1.102)  

I'm not interesting in any summary statistics, so that needn't be a problem. I'm assuming it's a question of converting the lm object to a data.frame and then using flip=TRUE but not sure how to go about it.

1

1 Answers

1
votes

You could extract the coefficients and their standard errors and then feed that to stargazer:

model.summary = coef(summary(model))[, 1:2]
stargazer(model.summary, flip=TRUE)

Here's what the PDF output looks like:

enter image description here