Anon
Anon

Reputation: 1

Stratified bootstrap zero-inflated poisson regression in R

Error code trying a stratified bootstrap in a zero-inflated poisson regression

Error: Error in tapply(seq_len(n), as.numeric(strata)) : 
  arguments must have same length
In addition: Warning message:
In tapply(seq_len(n), as.numeric(strata)) : NAs introduced by coercion

Bootstrapping without stratified variable results in error code: Error in optim(fn = loglikfun, gr = gradfun, par = c(start$count, start$zero,  : 
  non-finite value supplied by optim

New code with stratified VariableM which is a factor and contains 0 or 1 data (mostly 0)

f <- function(data, i) {
  require(pscl)
  m <- zeroinfl(VariableY ~ VariableX1 + VariableX2 + VariableX1:VariableX2
                | Variable1, data = data[i, ])
  as.vector(t(do.call(rbind, coef(summary(m)))[, 1:2]))
}

set.seed(1111)
res <- boot(data, f, R = 1000, strata = "VariableM")

Upvotes: 0

Views: 41

Answers (0)

Related Questions