How to add row to Stargazer table to indicate use of fixed effects

Viewed 4598

I just run my regression including fixed effects, in this case id_school. Next I omitted all the dummy variables from my stargazer tab, so I can save some space.

The thing is I want to include a row in my tab in order to report that I used Fixed Effect like :Fixed Effects Yes NO ...Something like the image.

Thank you. enter image description here

1 Answers

Simple option is to use Stargazer add.lines, e.g.

#load a panel data
data("Wages", package = "plm")

#plain vanilla OLS
model1 <- lm(lwage ~ exp + union + ed + black, data=Wages)
# Least-Squares Dummy Variables model
model2 <- lm(lwage ~ factor(ind) + exp + union + ed + black, data=Wages)

library(stargazer)

stargazer(model1, model2, omit = '[i][n][d]', type='text',
add.lines=list(c('Fixed effects', 'Yes','No'))
)

Returns:

=======================================================================
                                    Dependent variable:
                    ---------------------------------------------------
                                           lwage
                               (1)                       (2)
-----------------------------------------------------------------------
exp                         0.013***                  0.013***
                             (0.001)                   (0.001)

unionyes                    0.121***                  0.113***
                             (0.013)                   (0.013)

ed                          0.079***                  0.082***
                             (0.002)                   (0.002)

blackyes                    -0.269***                 -0.256***
                             (0.024)                   (0.024)

Constant                    5.374***                  5.313***
                             (0.036)                   (0.037)

-----------------------------------------------------------------------
Fixed effects                  Yes                       No
Observations                  4,165                     4,165
R2                            0.283                     0.291
Adjusted R2                   0.283                     0.290
Residual Std. Error     0.391 (df = 4160)         0.389 (df = 4159)
F Statistic         411.209*** (df = 4; 4160) 341.333*** (df = 5; 4159)
=======================================================================
Note:                                       *p<0.1; **p<0.05; ***p<0.01

If you are using Latex, another option is to use starpolishr available from github. This allows you to set the position of the line to be added.

library(stargazer)
library(tidyverse)
library(starpolishr)
stargazer(model1, model2, omit = '[i][n][d]', type='latex') %>%  
star_insert_row(insert.after=14, 'Fixed effets & Yes & No \\\\ ') %>% cat(file='foo.tex',sep='\n')

Output: this

Related