Skip to contents

Zero-inflated Poisson for the numerator process. Useful when overdispersion is primarily due to excess zeros.

Usage

ratiod_zipois(
  link_num = "log",
  link_denom = "log",
  link_zi = "logit",
  denom_family = "gamma"
)

Arguments

Link function for the count mean: "log".

Link function for the denominator mean: "log" (default); a gamma denominator also takes "identity" or "inverse".

Link function for the zero-inflation probability: "logit" (default), "probit" or "cloglog".

denom_family

Denominator distribution: "gamma" (default), "negbin" for a count denominator, or "fixed" for a known exposure.

Value

A ratiod_family object with zero-inflation

Details

Use ratiod_zipois() when:

  • Excess zeros are the main source of overdispersion

  • The non-zero counts follow Poisson (no additional overdispersion)

Use ratiod_zinegbin() when:

  • Both excess zeros AND overdispersion in positive counts

Examples

# Create family object
fam <- ratiod_zipois()
print(fam)
#> tulpaRatio family: zipois_gamma 
#> [Zero-inflated model]
#> Zero-inflated Poisson numerator, Gamma denominator 
#> 
#> Numerator:  poisson(log)
#> ZI prob:    bernoulli(logit)
#> Denominator: gamma (log) 

# Simulate zero-inflated CPUE data
set.seed(123)
n <- 60
zi_prob <- 0.25
df <- data.frame(
  catch = ifelse(runif(n) < zi_prob, 0, rpois(n, lambda = 5)),
  effort = rgamma(n, shape = 4, rate = 1),
  depth = rnorm(n),
  vessel = factor(rep(1:6, each = n/6))
)

# \donttest{
# Fit model
fit <- tratio(
  catch | effort ~ depth + (1 | vessel),
  data = df,
  family = ratiod_zipois(denom_family = "gamma"),
  control = list(iter = 400, chains = 1, seed = 1)
)
summary(fit)
#> ratio model summary
#> ===================
#> 
#> Inference: Exact (Tier 1) via hmc
#> Family: zipois_gamma 
#> 
#> Fixed effects (numerator):
#>        parameter  mean    sd   2.5% 97.5%  rhat ess_bulk
#>  num:(Intercept) 1.615 0.086  1.457 1.774 0.997      129
#>        num:depth 0.056 0.064 -0.063 0.177 1.005      127
#> 
#> Fixed effects (denominator):
#>          parameter  mean    sd  2.5% 97.5%  rhat ess_bulk
#>  denom:(Intercept) 1.411 0.064 1.293 1.544 1.022       79
#>        denom:depth 0.089 0.037 0.023 0.163 1.008      102
#> 
#> Variance components:
#>  parameter  mean    sd  2.5% 97.5%  rhat ess_bulk
#>      shape 6.605 1.146 4.691 8.926 1.007      124
#>   sigma_re 0.098 0.065 0.008 0.250 1.051       30
#> 
#> Zero/one inflation:
#>   parameter   mean    sd   2.5%  97.5%  rhat ess_bulk
#>  beta_zi[1] -1.023 0.283 -1.575 -0.396 1.043      106
#> 
#> Diagnostics:
#>   Divergences: 0 
#>   Avg. acceptance: 0.919 
#>   Chains: 1 
#>   Iterations: 400 
#>   Warmup: 200 
#>   R-hat > 1.01 for 3 parameter(s), largest 1.051 (sigma_re).
#>   Bulk ESS < 100 for 2 parameter(s), smallest 30 (sigma_re).
#>   Run longer chains or reparameterise before using these estimates.
# }