5

I obtain an error when using stargazer in conjunction with plm. Everything works fine for ordinary linear models. Here's an example:

library(plm)
library(stargazer)

# create test data
dat <- data.frame(y=runif(1000),
                  x1=runif(1000),
                  id=rep(1:50, each=20),
                  time=rep(1:20, times=50))
pdat <- pdata.frame(dat, index=c("id", "time"))

# estimate linear model
lm_1 <- lm(y~x1, data = pdat) 
summary(lm_1)
stargazer(lm_1, type="text", keep.stat = c("n"))

# estimate fixed effects model
plm_1 <- plm(y ~ x1, data=pdat, model = "within", effect = "individual")
summary(plm_1)
stargazer(plm_1, type="text", keep.stat = c("n"))

The last call returns

stargazer(plm_1, type="text", keep.stat = c("n"))
Error in UseMethod("logLik") : 
  no applicable method for 'logLik' applied to an object of class "c('plm', 'panelmodel')"

Thanks!

Max
  • 51
  • 3
  • Good question, it worked just fine for me: `======================================== Dependent variable: --------------------------- y ---------------------------------------- x1 -0.027 (0.032) ---------------------------------------- Observations 1,000 ======================================== Note: *p<0.1; **p<0.05; ***p<0.01 ` – M. Beausoleil Nov 14 '15 at 19:23
  • ditto.. no error on R3.2.2, stargazerv5.2 – user20650 Nov 14 '15 at 20:37
  • Thank you. I am also on R3.2.2 and stargazer 5.2. I have tried with plm 1.4 and 1.5.4. Must be my machine then — will keep investigating. – Max Nov 15 '15 at 19:22
  • @maximilian114, did it work with updated software? I just tested it with `R version 3.3.3`, `stargazer_5.2.1`, and `plm_1.6-6` it it worked without any errors. – Eric Fail Feb 10 '18 at 09:22
  • Works fine on updated software (R 3.4.1, stargazer 5.2.1). Thanks everyone! – Max Feb 11 '18 at 11:52
  • See also https://stackoverflow.com/questions/59528346/how-do-i-fix-the-unrecognized-object-error-in-stargazer-with-a-dynlm-model in my case, the issue was due to the fact that I called `plm::plm` making it impossible for stargazer to recognise the plm object. Loading `library(plm)` and calling `plm()` without the `plm::` prefix fixes it. – Paul Rougieux Mar 13 '21 at 00:00

0 Answers0