0

I have multiple linear models with the same dependent variables (Y) and a varying explanatory variables that I need to summarize in a table. However, stargazer adds the same Ys to the heading for each group of explanatory variables making the table unnecessarily wide. Is there anyway I can prevent this?

# control dummies
jan <- a$january
mon <- a$monday




y1 <- a$1
y2 <- a$2
y3 <- a$3

x1 <- a$4
x2 <- a$5
x3 <- a$6
m11 <- lm(y1~x1+jan+mon)
m21 <- lm(y2~x1+jan+mon)
m21 <- lm(y3~x1+jan+mon) 
m12 .... .... m33

My current guess is that it's due to the fact that I don't specify the data = in the lm model and the fact that some of the explanatory variables have less observations.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
First
  • 1
  • 1
  • 2

1 Answers1

2

First of all, it would be extremely helpful if you could simply paste the output you are seeing from stargazer here - otherwise we may simply not understand the issue you are facing (e.g., y1, y2, y3 are not the same and, hence, stargazer would obviously not recognize them as being the same)

Initial answer based on my understanding of your problem: For models that have the same dependent variable and are next to each other stargazer will automatically group the heading and won't report it twice:

Models with same DV that are next to each other

stargazer(model1, model1, model2, type = "text")

================================================================================
                                             Dependent variable:                
                              --------------------------------------------------
                                       daily_invcount2          daily_invcount3 
                                          negative                  negative    
                                          binomial                  binomial    
                                    (1)              (2)              (3)       
--------------------------------------------------------------------------------

Models with same DV that are not next to each other

stargazer(model1, model2, model1, type = "text")

================================================================================
                                             Dependent variable:                
                              --------------------------------------------------
                              daily_invcount2  daily_invcount3  daily_invcount2 
                                  negative         negative         negative    
                                  binomial         binomial         binomial    
                                    (1)              (2)              (3)       
--------------------------------------------------------------------------------

If this does not work for any particular reason stargazer offers three additional options:

  • If the DV is the same across all models you can turn off the dep var labels with dep.var.labels.include = FALSE and modify the overarching caption to something like dep.var.caption = "Dependent variable: DV 1"

  • If the DVs are different but are closely connected you could also edit the overarching dep var caption as above and overwrite the dep var labels with dep.var.labels = c("option a", "option b")

  • Finally, you can turn off the dep var labels, and split your models into custom groups and add manually defined column labels with (values are exemplary) column.separate = c(2, 1), column.labels = c("option a", "option b")

    I will update this answer as soon as I fully understand your issue.

Community
  • 1
  • 1
JNWHH
  • 721
  • 5
  • 11