Skip to contents

Trial-based model where the numerator represents successes out of denominator trials. The denominator can be treated as known (fixed) or modelled with its own process.

Use cases:

  • Detection / availability (occupancy-style)

  • Successes / trials (hierarchical binomial)

  • Proportions with known denominators

Usage

ratiod_binomial(link = "logit", denominator_known = TRUE)

Arguments

Link function for probability (default: "logit")

denominator_known

Logical; if TRUE, denominator is treated as fixed and known. If FALSE, denominator is also modelled.

Value

A ratiod_family object

Examples

# Create family object
fam <- ratiod_binomial()
print(fam)
#> tulpaRatio family: binomial_fixed 
#> Binomial numerator with fixed denominator 
#> 
#> Numerator:  binomial(logit)
#> Denominator: fixed (fixed) 

# Simulate detection/availability data
set.seed(123)
n <- 50
df <- data.frame(
  detections = rbinom(n, size = 10, prob = 0.4),
  trials = rep(10L, n),
  effort = rnorm(n),
  site = factor(rep(1:10, each = 5))
)

if (FALSE) { # \dontrun{
# Fit model (slow, not run on CRAN)
fit <- tratio(
  detections | trials ~ effort + (1 | site),
  data = df,
  family = ratiod_binomial(),
  control = list(iter = 200, warmup = 100, chains = 1)
)
} # }