Skip to contents

Two-process model where both numerator and denominator follow gamma distributions. This is the natural family for ratios of positive continuous quantities.

Use cases:

  • Biomass ratios (species biomass / total biomass)

  • Concentration ratios (analyte / reference)

  • Duration ratios (time in activity / total time)

Usage

ratiod_gamma_gamma(link_num = "log", link_denom = "log")

Arguments

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

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

Value

A ratiod_family object

Details

The gamma distribution is appropriate for positive continuous data with right skew. The ratio of two gamma random variables does not have a simple closed form, which is why ratio models them jointly.

Shape parameters are estimated for both numerator and denominator, allowing different amounts of variability in each process.

Examples

# Create family object
fam <- ratiod_gamma_gamma()
print(fam)
#> tulpaRatio family: gamma_gamma 
#> Gamma numerator, Gamma denominator (continuous ratios) 
#> 
#> Numerator:  gamma(log)
#> Denominator: gamma (log) 

# Simulate biomass ratio data
set.seed(123)
n <- 50
df <- data.frame(
  species_biomass = rgamma(n, shape = 3, rate = 0.5),
  total_biomass = rgamma(n, shape = 10, rate = 0.3),
  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(
  species_biomass | total_biomass ~ habitat + (1 | site),
  data = df,
  family = ratiod_gamma_gamma(),
  control = list(iter = 200, warmup = 100, chains = 1)
)
} # }