Skip to contents

Zero-inflated negative binomial for the numerator process. Models excess zeros as a mixture:

$$P(Y = 0) = \pi + (1 - \pi) \cdot P_{NB}(0)$$ $$P(Y = y) = (1 - \pi) \cdot P_{NB}(y), \quad y > 0$$

where \(\pi\) is the zero-inflation probability and \(P_{NB}\) is the negative binomial PMF.

Usage

ratiod_zinegbin(
  link_num = "log",
  link_denom = "log",
  link_zi = "logit",
  denom_family = "negbin"
)

Arguments

Link function for count mean (default: "log")

Link function for denominator mean (default: "log")

Link function for zero-inflation probability (default: "logit")

denom_family

Denominator distribution: "negbin" (default) or "fixed"

Value

A ratiod_family object with zero-inflation

Details

The zero-inflation probability can have its own linear predictor via the zi argument in tratio(). If not specified, a single intercept is estimated.

For ecological data, zero-inflation often represents:

  • Structural zeros (species truly absent vs not detected)

  • Sampling zeros (inadequate effort)

  • False negatives

See also

ratiod_hurdle_negbin() for hurdle model alternative

Examples

# Create family object
fam <- ratiod_zinegbin()
print(fam)
#> tulpaRatio family: zinegbin_negbin 
#> [Zero-inflated model]
#> Zero-inflated negative binomial numerator, negative binomial denominator 
#> 
#> Numerator:  neg_binomial_2(log)
#> ZI prob:    bernoulli(logit)
#> Denominator: neg_binomial_2 (log) 

# Simulate zero-inflated count data
set.seed(123)
n <- 60
zi_prob <- 0.3
df <- data.frame(
  count = ifelse(runif(n) < zi_prob, 0, rnbinom(n, size = 3, mu = 8)),
  total = rnbinom(n, size = 5, mu = 50),
  habitat = factor(rep(c("forest", "grassland"), each = n/2)),
  site = factor(rep(1:10, each = n/10))
)

if (FALSE) { # \dontrun{
# Fit model (not run - ZI models require specialized backend support)
fit <- tratio(
  count | total ~ habitat + (1 | site),
  data = df,
  family = ratiod_zinegbin(),
  control = list(iter = 200, warmup = 100, chains = 1)
)
} # }