jashu / beset

Best Subset Predictive Modeling
5 stars 0 forks source link

Error calculating pseudo R2 for intercept-only ZINB built with pscl::zeroinfl using beset::r2d #11

Closed sahirt closed 2 years ago

sahirt commented 2 years ago

I'm trying to calculate the pseudo R2 value for a zero-inflated, negative binomial model built with pscl::zeroinfl, using beset::r2d.

Here are the relevant excerpts from my code:

fish <- read.csv('fish.csv', header=TRUE, row.names = 1)
fish$site.ID <- as.factor(fish$site.ID)
fish$year <- as.factor(fish$year)
colnames(fish)[16] <- "phylo"
library(MASS)
library(pscl)
m14 <- zeroinfl(phylo ~ site.ID + year + site.ID:year + standard.length | 1, data = fish, dist = "negbin")
summary(m14)

The model (m14) contains an intercept-only zero-inflation component. Whenever I go to run r2d(m14), I get the error

Error in rep_len(prob, LLL) : cannot replicate NULL to a non-zero length

I don't understand where this error is coming from. Can you advise on how to troubleshoot?

jashu commented 2 years ago

Thank you so much for pointing this out--this was a bug on my end which should now be fixed. Please uninstall and reinstall the current version from GitHub, and let me know if this fixes the error.