0

I am currently doing some panel data regressions in R and I am trying to put multiple models side-by-side using stargazer

When I put 5 panel data models using stargazer I receive an output

reglogglobal2 <- plm(log1p(GDP_growth) ~ log1p(CO2emissions_per_capita) + log1p(inflation) + log1p(forest_area_sq_km) + log1p(nitrous_oxide_emissions) + log1p(methane_emissions), data = pdataglobal, model = "within")
stargazer(reglogglobal2, reglogglobal, reglog32, reglog33, reglog31,reg1og56,
          type = "text",
          header = FALSE,
          no.space = TRUE)

but when I put 6 I receive this error

enter image description here

Error in if (is.na(s)) { : the condition has length > 1

All my models and dataframes are defined . What does this error mean ? How can I solve it please ? Thank you

I was able to produce stargazer output with 6 lm models so I can confirm that stargazer works with 6 linear regressions. Not sure if it is because I am using panel data .

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • In which line does it error? The call to `plm` or the call to `stargazer`? If the former, there's no need to include `stargazer` in the code or the tags. – r2evans Apr 03 '23 at 16:46
  • I suspect `plm`. I couldn't immediately find a reference to `is.na(a)` in the `plm` function itself, so it's likely buried deeper in the package. I suggest you go through the various functions in the [package source](https://github.com/ycroissant/plm/tree/main/R) and/or raise a [new issue](https://github.com/ycroissant/plm/issues/new) with a reproducible example (including sample data). Unless somebody has run into that before, there's likely not a lot more we can do without a reproducible example (see https://stackoverflow.com/q/5963269). – r2evans Apr 03 '23 at 16:50
  • 3
    You don't really give us enough info to answer your question, since we don't have the data to reproduce it. What I'd suggest is pretty generic: make sure all your packages are up to date (run `update.packages(ask = FALSE)` to do this), then if you still get the error, run `traceback()` after it, and if that doesn't tell you how to fix it, edit your question to include the `traceback()` results. – user2554330 Apr 03 '23 at 16:50
  • 2
    Obligatory mention that ‘stargazer’ is an all round terrible package. I strongly recommend not using it. There are lots of better alternatives, such as ‘modelsummary’ or “texreg’. – Konrad Rudolph Apr 03 '23 at 17:11
  • @r2evans . It is a stargazer issue. Thanks – Progress_regress Apr 03 '23 at 17:38
  • Turns out the issue was the long object names . I shortened it and the stargazer function now is working is displaying all 6 regressions without any error message. Thank you everyone for their help – Progress_regress Apr 03 '23 at 21:02

0 Answers0