The Core Problem
Ecologists routinely analyse ratios: catch per unit effort (CPUE), species per unit area, biomass per trawl hour, detections per camera-night. The standard approach is to compute the ratio and model it directly:
# The WRONG approach (don't do this)
data$cpue <- data$catch / data$effort
lm(cpue ~ depth + season, data = data)This approach is fundamentally flawed. Here’s why.
Ratios Inherit Correlated Errors
When you divide two measured quantities, the ratio inherits uncertainty from both. If catch and effort share any common drivers—observer effects, site conditions, temporal autocorrelation—those dependencies propagate into the ratio in complex, non-linear ways.
Consider a simple example: two sites with identical true CPUE, but different effort levels.
| Site | True rate | Effort | Expected catch | Observed catch | Observed CPUE |
|---|---|---|---|---|---|
| A | 5 | 10 | 50 | 48 | 4.8 |
| B | 5 | 100 | 500 | 512 | 5.12 |
Site B’s CPUE estimate is more precise simply because it has more effort. But a ratio-based model treats both CPUE values as equally informative. This is heteroscedasticity by construction. ## The Offset Fallacy
A common “fix” is to use an offset:
This assumes the ratio is the quantity of interest and that effort affects catch proportionally with coefficient exactly 1. Neither assumption is generally true:
Effort has its own structure: Effort varies systematically—more effort in accessible sites, during good weather, when funding permits. These patterns create confounding.
The proportionality assumption fails: A 10% increase in effort rarely yields exactly 10% more catch. Saturation effects, interference between sampling units, and diminishing returns are common.
Uncertainty in effort is ignored: Effort measurements have error. Offset models treat effort as fixed and known.
The numdenom Solution: Joint Modelling
numdenom takes a different approach. Instead of modelling the ratio, we jointly model the two processes that generate it:
with linked linear predictors:
The ratio is then a derived quantity, computed in the posterior:
Why Shared Structure Matters
The key insight is the shared random effect . This term enters both the numerator and denominator linear predictors identically.
Why does this matter? Consider what happens without shared structure:
- Site A has high catch AND high effort (good conditions)
- Site B has low catch AND low effort (poor conditions)
- An independent model sees: “A has high catch given its predictors” and “A has high effort given its predictors”
- These residuals are positively correlated but modeled as independent
- The ratio inherits spurious variation from this ignored correlation
With shared structure:
- The shared effect captures “site quality”
- High-quality sites have high , boosting BOTH catch and effort expectations
- The shared effect cancels in the ratio (it appears in both and )
- What remains is the true ratio signal, not confounded by site quality
This is why numdenom makes shared structure the default. Independence is a special case that must be explicitly requested—and triggers a warning.
The Three Families
numdenom provides three model families for different data types:
1. Two-Process Counts: ratiod_negbin_negbin()
Both numerator and denominator are overdispersed counts:
Use cases: Species count / total count, events / opportunities
This is the family for the “hard case”—what people cannot do correctly with binomial models.
Full Uncertainty Propagation
Because ratios are computed from the full posterior, every draw reflects uncertainty in:
- Fixed effect estimates
- Random effect realizations
- Overdispersion parameters
- Spatial/temporal structure
This is exact posterior inference on the ratio, not an approximation or delta-method estimate.
When Independence Is Appropriate
There are cases where shared structure is not needed:
Designed experiments: If effort is controlled and randomized, it may be independent of the outcome process.
Known denominators: Population counts from a census, predetermined sample sizes.
Different observation processes: If numerator and denominator are measured by completely independent methods with no common drivers.
In these cases, use shared = ~ 0:
fit <- tratio(
successes | trials ~ treatment,
shared = ~ 0, # Explicit independence (triggers warning)
family = ratiod_binomial(),
data = experiment_data
)The warning reminds you that this is a strong assumption.
Summary
| Approach | Problem |
|---|---|
| Model ratio directly | Heteroscedasticity, ignores denominator uncertainty |
| Use offset | Assumes proportionality, ignores effort structure |
| Independent joint model | Spurious ratio effects from shared unmeasured drivers |
| numdenom (shared structure) | Correct propagation of uncertainty, shared drivers cancel |
numdenom enforces the correct approach by design:
- No offsets allowed
- Shared structure by default
- Independence requires explicit request
- Ratios computed post hoc with full uncertainty
Further Reading
- Simpson, D. et al. (2017). Penalising model component complexity. Statistical Science.
- Conn, P. B. et al. (2017). Hierarchical modeling of false-positive errors in acoustic surveys. Ecology.
- Royle, J. A. & Dorazio, R. M. (2008). Hierarchical Modeling and Inference in Ecology. Academic Press.