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.

Mackenzie
  • 91
  • 1
  • 3
  • does `m1$coefficients[1:2]` meet your needs? – G5W Mar 19 '18 at 17:34
  • Not really - stargazer takes the full model. Specifying only the coefficients would remove all the other info stargazer uses to make a table. – Mackenzie Mar 19 '18 at 17:36
  • 7
    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. – MrFlick Mar 19 '18 at 19:35

1 Answers1

0

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
Marco
  • 2,368
  • 6
  • 22
  • 48