4

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

DanY
  • 5,920
  • 1
  • 13
  • 33
RfSg
  • 41
  • 1
  • 2
  • Use the `add.lines` argument to `stargazer()` to add a row to your table that indicates you used fixed effects. – DanY Jun 05 '20 at 22:09
  • 1
    Note that I edited your question to be about stargazer and not rstudio. You also asked a second question about your data being balanced, which I deleted from here, since it is unrelated. If you still have that question, ask it in a new stackoverflow post. – DanY Jun 05 '20 at 22:12

1 Answers1

11

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

Otto Kässi
  • 2,943
  • 1
  • 10
  • 27