2

I am having some trouble reporting results from a series of zero inflated poisson regressions. I am trying to use stargazer to output the results. I'm starting with the dummy data from UCLA, and some dummy regressions:

# This example comes directly from http://statistics.ats.ucla.edu/stat/r/dae/zipoisson.html

library('stargazer')
library('pscl')
library('boot')

zinb <- read.csv("https://stats.idre.ucla.edu/stat/data/fish.csv")
zinb <- within(zinb, {
  nofish <- factor(nofish)
  livebait <- factor(livebait)
  camper <- factor(camper)
})


m1 <- zeroinfl(count ~ child + camper | persons, data = zinb)
m2 <- zeroinfl(count ~ child + camper + livebait | persons, data = zinb)
m3 <- zeroinfl(count ~ child + camper + livebait + persons | persons, data = zinb)

My problem is twofold. First, I generally use the stargazer package for output because I'm familiar with it. However, it splits the output into the zero component/logistic regression output and the poisson output. Is there a way to combine these in one output?

#stargazer for output
stargazer(m1, m2, m3,
          title = "zero inflated poisson",
          align = TRUE, type = "text",
          column.labels = c("model1", "model2", "model3"),
          star.cutoffs = c(0.05, 0.01, 0.001)
          
)


#stargazer for output
stargazer(m1, m2, m3,
          title = "zero inflated poisson",
          align = TRUE, type = "text",
          column.labels = c("model1", "model2", "model3"),
          star.cutoffs = c(0.05, 0.01, 0.001),
          zero.component = TRUE

)

Second, I would really like to report the results for the non-zero component in IRR and the zero component in OR. I cannot figure out how to do this in stargazer. I tried the following, but can't get it work:

irrs <- lapply(list(m1, m2, m3), function(model) {
  exp(coef(model))
})


#stargazer for output
stargazer(m1, m2, m3,
          title = "zero inflated poisson",
          align = TRUE, type = "text",
          column.labels = c("model1", "model2", "model3"),
          star.cutoffs = c(0.05, 0.01, 0.001),
          coef = lapply(irrs, function(x) paste(round(x, 2), "IRR", sep = " x "))
)

% Error: Argument 'coef' must be NULL (default), or a list of numeric vectors.
tchoup
  • 971
  • 4
  • 11
  • 5
    [‘stargazer’ is a terrible package](https://www.reddit.com/r/rstats/comments/6o9v9h/comment/dkgw9q1/). I strongly recommend against using it. Use *anything* else instead, e.g. ‘[modelsummary](https://vincentarelbundock.github.io/modelsummary/)’ or ‘[texreg](https://cran.r-project.org/web/packages/texreg/index.html)’. – Konrad Rudolph May 30 '23 at 14:10

1 Answers1

1

try this solution with modelsummary

library('pscl')
library('boot')
library(modelsummary)
zinb <- read.csv("https://stats.idre.ucla.edu/stat/data/fish.csv")
zinb <- within(zinb, {
  nofish <- factor(nofish)
  livebait <- factor(livebait)
  camper <- factor(camper)
})


m1 <- zeroinfl(count ~ child + camper | persons, data = zinb)
m2 <- zeroinfl(count ~ child + camper + livebait | persons, data = zinb)
m3 <- zeroinfl(count ~ child + camper + livebait + persons | persons, data = zinb)


modelsummary(models = list(model1= m1,model2 = m2,model3 =m3), exponentiate = TRUE,
             stars = TRUE, title = "zero inflated poisson")
Mike
  • 3,797
  • 1
  • 11
  • 30