Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using stargazer for lfe and getting error

Tags:

r

latex

stargazer

I am trying to use stargazer package after estimating model with felm (from lfe package) and getting error, maybe somebody could provide help on this. Below I provide a simple example.

library(lfe)
library(stargazer)
oldopts <- options(lfe.threads=1)
x <- rnorm(1000)
x2 <- rnorm(length(x))
id <- factor(sample(10,length(x),replace=TRUE))
firm <- factor(sample(3,length(x),replace=TRUE,prob=c(2,1.5,1)))
year <- factor(sample(10,length(x),replace=TRUE,prob=c(2,1.5,rep(1,8))))
id.eff <- rnorm(nlevels(id))
firm.eff <- rnorm(nlevels(firm))
year.eff <- rnorm(nlevels(year))
y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] +year.eff[year] + rnorm(length(x))
est <- felm(y ~ x+x2 | id + firm + year)
stargazer(est)

I get the following error:

Error in if (.global.coefficient.variables[i] %in% .global.intercept.strings) { : argument is of length zero

like image 317
Vitalijs Avatar asked May 20 '15 11:05

Vitalijs


1 Answers

The new stargazer update (to version 5.2) fixed this issue for me.

Simply update your stargazer and lfe packages via

update.packages()

Make sure to restart your R session after you updated your packages and reload the lfe (lfe_2.3-1709) and stargazer (stargazer_5.2) libraries so that you can be certain that the updated packages are loaded.

like image 84
Phil Avatar answered Oct 21 '22 05:10

Phil