Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep just one variable in stargazer regression output? (oposite of "omit")

Does anyone know what could be the opposite of stargazer's argument "omit" when making a regression table output?

I'm trying to show just one (or a few) covariates from a regression. I know one could use "omit" and then list all the variable's names which one doesn't want to be shown in the output, but is there any way to call variable's names one actually wants to maintain in the final table?

I'm having a hard time dealing with interactions between dummy variables directly called within a linear model. For example, let's say I want to run the following model:

# Libraries
library(stargazer)

# Data:
data <- data.frame(
  "Y" = rnorm(100,20,45),
  "Dummy1" = sample(c(1,0),100, replace = T),
  "Dummy2" = sample(c(1,0),100, replace = T),
  "Dummy3" =sample(c(1,0),100, replace = T))

# Model:
model1 <- lm(Y ~ Dummy1*Dummy2*Dummy3, data)

And let's say I want to report in the output stargazer table only the triple interaction. But when I try, for example, to remove the results of the simple variable "Dummy1", stargazer drops all the variables that begin with "Dummy1" therefore also removing the triple interaction.

# Problem
stargazer(model1, type = "text", omit = "Dummy1")


===============================================
                        Dependent variable:    
                    ---------------------------
                                 Y             
-----------------------------------------------
Dummy2                        23.705           
                             (17.236)          
                                               
Dummy3                        19.221           
                             (17.591)          
                                               
Dummy2:Dummy3                 -25.568          
                             (23.908)          
                                               
Constant                       5.373           
                             (12.188)          
                                               
-----------------------------------------------
Observations                    100            
R2                             0.099           
Adjusted R2                    0.031           
Residual Std. Error      43.943 (df = 92)      
F Statistic             1.450 (df = 7; 92)     
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01

How do I make a table with just the triple interaction's result ? Any guess?

like image 584
Guibor Camargo Salamanca Avatar asked Nov 15 '25 07:11

Guibor Camargo Salamanca


1 Answers

Instead of using omit, you can use keep to keep only the variables that you need.

stargazer::stargazer(model1, type = "text", keep = 'Dummy1:Dummy2:Dummy3')

================================================
                         Dependent variable:    
                     ---------------------------
                                  Y             
------------------------------------------------
Dummy1:Dummy2:Dummy3           42.430           
                              (35.315)          
                                                
------------------------------------------------
Observations                     100            
R2                              0.145           
Adjusted R2                     0.080           
Residual Std. Error       43.587 (df = 92)      
F Statistic             2.222** (df = 7; 92)    
================================================
Note:                *p<0.1; **p<0.05; ***p<0.01
like image 124
Ronak Shah Avatar answered Nov 17 '25 20:11

Ronak Shah