atahk / pscl

Political Science Computational Laboratory
65 stars 14 forks source link

Confused on the Hurdle model prediction calculation #15

Closed jingsliu07 closed 4 years ago

jingsliu07 commented 4 years ago

Dear authors, thanks for providing the pscl package and we've been using it to fit hurdle and zero-inflated models.

I have a question on hurdle model prediction when going through the source code in comparison to your tech document, and hope if you mind sparing some time to help if I missed anything.

The source code here seems to indicate that p0_zero is the log-probability of observing 0 based on the binary model, and p0_count is the log-probability of observing 0 based on the count model. https://github.com/atahk/pscl/blob/7db2395361acc69ca8b875762fe9117541f76e77/R/hurdle.R#L624

But based on your tech doc Appendix C (clipped below), image

it seems the line

logphi <- p0_zero - p0_count
if(type == "zero") rval <- exp(logphi)

ought to be

logphi <- log(1-exp(p0_zero)) - log(1 - exp(p0_count))
if(type == "zero") rval <- exp(logphi)

instead?

jingsliu07 commented 4 years ago

Oh I missed the lower.tail = FALSE part! NVM!