Two-process model where both numerator and denominator follow negative binomial distributions. This is the core family for count-count ratios where both processes exhibit overdispersion.
Use cases:
Species counts / total counts (relative abundance)
Events / opportunities (both counts)
Any ratio where numerator and denominator are overdispersed counts
Examples
# Create family object
fam <- ratiod_negbin_negbin()
print(fam)
#> tulpaRatio family: negbin_negbin
#> Negative binomial numerator, negative binomial denominator
#>
#> Numerator: neg_binomial_2(log)
#> Denominator: neg_binomial_2 (log)
# Simulate data for relative abundance
set.seed(123)
n <- 60
df <- data.frame(
sp_count = rnbinom(n, size = 5, mu = 15),
total_count = rnbinom(n, size = 8, mu = 100),
habitat = factor(rep(c("forest", "grassland"), each = n/2)),
site = factor(rep(1:10, each = n/10))
)
if (FALSE) { # \dontrun{
# Fit model (slow, not run on CRAN)
fit <- tratio(
sp_count | total_count ~ habitat + (1 | site),
data = df,
family = ratiod_negbin_negbin(),
control = list(iter = 200, warmup = 100, chains = 1)
)
} # }