Omit output of a factor variable in stargazer?
Asked Answered
S

1

8

If I'm running a fixed effects model in r using lm and the factor command, how can I suppress the factor variable coefficients in a stargazer model?

i.e. my model is:

m1<-lm(GDP~pop_growth + factor(city))

and I want to report findings with only an intercept and coefficient on pop_growth, not coefficients on every dummy variable for cities.

EDIT: Issue was, as it turns out, with variable name encoding. omit="city" works.

Sojourn answered 19/3, 2018 at 17:24 Comment(3)
does m1$coefficients[1:2] meet your needs?Frondescence
Not really - stargazer takes the full model. Specifying only the coefficients would remove all the other info stargazer uses to make a table.Sojourn
You shouldn't edit your question to include an answer. If you solve your own problem, add it as an separate answer post below. This will properly mark the question as answered and will more easily help others in the future find and vote on a solution.Carrycarryall
M
1

As the author said there is an omit option:

library(stargazer)

model<-lm(mpg~disp+factor(cyl), data=mtcars)

stargazer(model, type="text", omit="cyl")

===============================================
                        Dependent variable:    
                    ---------------------------
                                mpg            
-----------------------------------------------
disp                         -0.027**          
                              (0.011)          
                                               
Constant                     29.535***         
                              (1.427)          
                                               
-----------------------------------------------
Observations                    32             
R2                             0.784           
Adjusted R2                    0.760           
Residual Std. Error       2.950 (df = 28)      
F Statistic           33.807*** (df = 3; 28)   
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01
Modicum answered 12/1, 2023 at 11:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.