Negative Binomial-Gamma Family for Overdispersed Count/Effort Ratios
Source:R/family.R
ratiod_negbin_gamma.RdTwo-process model where the numerator follows a negative binomial distribution and the denominator (effort/exposure) follows a Gamma distribution. This fills the gap between Poisson-Gamma (equidispersed counts) and NegBin-NegBin (integer denominator): use it when counts are overdispersed and effort is continuous.
Use cases:
Overdispersed catch per unit effort (CPUE)
Overdispersed observations per continuous exposure
Any ratio of overdispersed counts over continuous positive effort
Examples
# Create family object
fam <- ratiod_negbin_gamma()
print(fam)
#> tulpaRatio family: negbin_gamma
#> Negative binomial numerator, Gamma denominator (overdispersed CPUE-type)
#>
#> Numerator: neg_binomial_2(log)
#> Denominator: gamma (log)
# Simulate overdispersed CPUE data
set.seed(123)
n <- 60
df <- data.frame(
catch = rnbinom(n, size = 5, mu = 8),
effort_hours = rgamma(n, shape = 4, rate = 1),
depth = rnorm(n),
vessel = factor(rep(1:6, each = n/6))
)
# \donttest{
# Fit model
fit <- tratio(
catch | effort_hours ~ depth + (1 | vessel),
data = df,
family = ratiod_negbin_gamma(),
control = list(iter = 400, chains = 1, seed = 1)
)
summary(fit)
#> ratio model summary
#> ===================
#>
#> Inference: Exact (Tier 1) via hmc
#> Family: negbin_gamma
#>
#> Fixed effects (numerator):
#> parameter mean sd 2.5% 97.5% rhat ess_bulk
#> num:(Intercept) 2.025 0.078 1.843 2.140 1.022 32
#> num:depth 0.070 0.069 -0.071 0.189 1.026 57
#>
#> Fixed effects (denominator):
#> parameter mean sd 2.5% 97.5% rhat ess_bulk
#> denom:(Intercept) 1.319 0.100 1.041 1.468 1.040 23
#> denom:depth 0.029 0.077 -0.122 0.186 1.034 102
#>
#> Variance components:
#> parameter mean sd 2.5% 97.5% rhat ess_bulk
#> phi_denom 3.794 0.663 2.760 5.283 0.997 103
#> phi_num 9.841 4.212 4.272 19.860 1.006 128
#> sigma_re 0.087 0.074 0.006 0.302 1.002 46
#>
#> Diagnostics:
#> Divergences: 0
#> Avg. acceptance: 0.86
#> Chains: 1
#> Iterations: 400
#> Warmup: 200
#> R-hat > 1.01 for 4 parameter(s), largest 1.040 (denom:(Intercept)).
#> Bulk ESS < 100 for 4 parameter(s), smallest 23 (denom:(Intercept)).
#> Run longer chains or reparameterise before using these estimates.
# }