0

I'm trying to omit variables that appear in some models but not in others. However, I'm not getting the output I expect. I'm using stargazer 5.2. Here's a MWE:

y <- rbinom(100, 1, 0.5)
x <- rnorm(100)
z <- rnorm(100)

fit1.lm <- lm(y~x)
fit2.lm <- lm(y~x+z)
stargazer(fit.lm, fit2.lm,
          omit=c("x", "z"), 
          omit.labels=c("x", "z"))

This gives the following output in the omitted section.

x & Yes & Yes \\ 
z & No & No \\ 

The entry in the second row and second column should be a Yes.

pbaylis
  • 1,529
  • 11
  • 19

1 Answers1

0

As the answer by scoa indicates, change the models.

stargazer(fit2.lm, fit1.lm,
          omit=c("x", "z"), 
          omit.labels=c("x", "z"), type="text")

=========================================================
                             Dependent variable:         
                    -------------------------------------
                                      y                  
                           (1)                (2)        
---------------------------------------------------------
Constant                 0.493***           0.498***     
                         (0.051)            (0.050)      
                                                         
---------------------------------------------------------
x                          Yes                Yes        
z                          Yes                 No        
---------------------------------------------------------
Observations               100                100        
R2                        0.019              0.007       
Adjusted R2               -0.002             -0.003      
Residual Std. Error  0.503 (df = 97)    0.503 (df = 98)  
F Statistic         0.916 (df = 2; 97) 0.739 (df = 1; 98)
=========================================================
Note:                         *p<0.1; **p<0.05; ***p<0.01
Marco
  • 2,368
  • 6
  • 22
  • 48