rregressionsummarystargazer

Stargazer: Omit variables and replace with yes/no


How can I omit several groups of covariates from the regression table and replace them with the group labels in stargazer? For example, if under city controls there is size and population, and under individual controls there is age and gender, how can I omit size, population, age, and gender and instead have something like city controls in the model?: no yes and individual controls in the model?: no yes.

By the way, all covariates from the same group would join or leave the model together.


Solution

  • Please provide a minimal example. Perhaps you are looking for something like this:

    data("Produc", package="plm")
    
    Produc$cat <- cut(Produc$gsp,
                  breaks=quantile(Produc$gsp),
                  labels=c('Bad', 'OK', 'Good', 'Great'))
    
    fe <- plm(pcap ~ hwy + water + unemp + cat,
        data=Produc, index=c("state", "year"), model = "within")
    
    stargazer(fe, type="text")
    
    ========================================
                     Dependent variable:    
                 ---------------------------
                            pcap            
    ----------------------------------------
    hwy                   2.025***          
                           (0.054)          
                                            
    water                 1.976***          
                           (0.043)          
                                            
    unemp                  -17.644          
                          (19.716)          
                                            
    catOK                 462.982*          
                          (269.838)         
                                            
    catGood               679.697**         
                          (329.131)         
                                            
    catGreat               430.046          
                          (388.285)         
                                            
    ----------------------------------------
    Observations             815            
    R2                      0.902           
    Adjusted R2             0.895           
    F Statistic  1,170.861*** (df = 6; 761) 
    ========================================
    Note:        *p<0.1; **p<0.05; ***p<0.01
    

    Use the option omit to omit certain variables. And option add.lines to add any note you like.

    stargazer(fe, type="text", omit = "cat")
    stargazer(fe, type="text", omit = "cat", 
              add.lines=list(c("Cats", "YES")))
    
    ========================================
                     Dependent variable:    
                 ---------------------------
                            pcap            
    ----------------------------------------
    hwy                   2.025***          
                           (0.054)          
                                            
    water                 1.976***          
                           (0.043)          
                                            
    unemp                  -17.644          
                          (19.716)          
                                            
    ----------------------------------------
    Cats                     YES            
    Observations             815            
    R2                      0.902           
    Adjusted R2             0.895           
    F Statistic  1,170.861*** (df = 6; 761) 
    ========================================
    Note:        *p<0.1; **p<0.05; ***p<0.01