1

I wanted to ask when doing panel data models: random, fixed and LSDV using lm function. When using stargazer to get nice table of results, we get a additional variables coef for all cross section dummy coefs. like in the example below:

#Load packages
library(foreign)
library(plm)
library(stargazer)

#Load in Wooldridge data on crime
crime <- read.dta("http://fmwww.bc.edu/ec-p/data/wooldridge/crime4.dta")

#Declare our data to be a panel data set
crime.p <- pdata.frame(crime,index=c("county","year"))

#Run a panel model
#fixed effects / within
fixedeff <- plm(log(crmrte) ~ polpc + lwtuc + avgsen + wfed + d82 + d82 + d84 + d85,data=crime.p,model="within")

#Random effects
randomeff <- plm(log(crmrte) ~ polpc + lwtuc + avgsen + wfed + d82 + d82 + d84 + d85,data=crime.p,model="random")

#LSDV
LSDV <- lm(log(crmrte) ~ polpc + lwtuc + avgsen + wfed + d82 + d82 + d84 + d85 + factor(county)-1, data=crime.p)

stargazer(fixedeff, randomeff, LSDV, type = "text")

Is there a way how to have a nice table and do not have all factor(county) coefs in it?

I know we can do it "by hand" when printing the table, however I need this inside a function So I NEED type = "text".

Petr
  • 1,606
  • 2
  • 14
  • 39
  • Looking at `?stargazer`, there are quite a few options for `omit = ...`. Maybe that helps? – coffeinjunky Nov 28 '19 at 09:25
  • I know about `omit` argument, I dont know how to implement it in script – Petr Nov 28 '19 at 09:33
  • I think if you boiled it down to your exact problem with a minimum reproducable example (including data, e.g. use `mtcars` or similar), it would be easier for people to help you. See e.g. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Right now we have to guess what the problem with `omit` might be. – coffeinjunky Nov 28 '19 at 09:36
  • Hi @Petr if the solutions works for you, I'd love to get an upvote. Best regards, Marco – Marco Dec 04 '19 at 07:43

1 Answers1

1

as coeffeinjunky said, it should work with omit. Add it as option to stargazer:

stargazer(fixedeff, randomeff, LSDV, type = "text", omit=c("county"))

Is this the output you're looking for?

Marco
  • 2,368
  • 6
  • 22
  • 48