Skip to contents

Trial-based model where the numerator represents successes out of a known number of trials, the denominator.

Use cases:

  • Detection / availability (occupancy-style)

  • Successes / trials (hierarchical binomial)

  • Proportions with known denominators

Usage

ratiod_binomial(link = "logit")

Arguments

Link function for the success probability: "logit" (default), "probit" or "cloglog".

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))
)

# \donttest{
# Fit model
fit <- tratio(
  detections | trials ~ effort + (1 | site),
  data = df,
  family = ratiod_binomial(),
  control = list(iter = 400, chains = 1, seed = 1)
)
summary(fit)
#> ratio model summary
#> ===================
#> 
#> Inference: Exact (Tier 1) via hmc
#> Family: binomial_fixed 
#> 
#> Fixed effects (numerator):
#>        parameter   mean    sd   2.5%  97.5%  rhat ess_bulk
#>  num:(Intercept) -0.357 0.118 -0.571 -0.147 1.033      113
#>       num:effort  0.131 0.107 -0.074  0.309 1.033       50
#> 
#> Variance components:
#>  parameter  mean    sd  2.5% 97.5%  rhat ess_bulk
#>   sigma_re 0.222 0.157 0.008 0.568 1.181        6
#> 
#> Diagnostics:
#>   Divergences: 0 
#>   Avg. acceptance: 0.901 
#>   Chains: 1 
#>   Iterations: 400 
#>   Warmup: 200 
#>   R-hat > 1.01 for 3 parameter(s), largest 1.181 (sigma_re).
#>   Bulk ESS < 100 for 2 parameter(s), smallest 6 (sigma_re).
#>   Run longer chains or reparameterise before using these estimates.
# }