Skip to contents

Compare multiple ratio models using LOO-CV or WAIC.

Usage

ratiod_compare(..., criterion = c("loo", "waic"))

Arguments

...

Multiple ratiod_fit objects to compare

criterion

Comparison criterion: "loo" (default) or "waic"

Value

A loo_compare object

Examples

# \donttest{
# Fit models with different structures (slow, not run on CRAN)
set.seed(123)
n <- 50
df <- data.frame(
  y_num = rnbinom(n, size = 5, mu = 15),
  y_denom = rnbinom(n, size = 8, mu = 100),
  x = rnorm(n),
  z = rnorm(n)
)
fit1 <- tratio(y_num | y_denom ~ x, data = df,
              family = ratiod_negbin_negbin(),
              control = list(iter = 200, warmup = 100, chains = 1))
#> Inference: Exact (Tier 1)
#>   Backend: hmc
#>   Reason: default (full MCMC)
#> Fitting ratio model...
#>   Family: negbin_negbin
#>   Observations: 50
#>   Iterations: 200 (warmup: 100)
#> Running NUTS sampler...
#>   Parameters: 6
#>   Iterations: 200 (warmup: 100)
#>   Chains: 1 (cores: 1)
fit2 <- tratio(y_num | y_denom ~ x + z, data = df,
              family = ratiod_negbin_negbin(),
              control = list(iter = 200, warmup = 100, chains = 1))
#> Inference: Exact (Tier 1)
#>   Backend: hmc
#>   Reason: default (full MCMC)
#> Fitting ratio model...
#>   Family: negbin_negbin
#>   Observations: 50
#>   Iterations: 200 (warmup: 100)
#> Running NUTS sampler...
#>   Parameters: 8
#>   Iterations: 200 (warmup: 100)
#>   Chains: 1 (cores: 1)
# Compare (requires loo package)
# ratiod_compare(fit1, fit2)
# }