Using stargazer for lfe and getting error
Asked Answered
B

1

7

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

Barberabarberry answered 20/5, 2015 at 11:16 Comment(1)
This might be a bug, as felm model is in the list of supported objects (cran.r-project.org/web/packages/stargazer/stargazer.pdf). You probably should contact the maintainer: maintainer("stargazer").Wolfy
G
1

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.

Glume answered 16/7, 2015 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.