Compute posterior distributions of contrasts (differences or ratios) between conditions for the derived ratio quantity.
Examples
# \donttest{
# Generate synthetic data with grouping variable
set.seed(456)
n <- 60
df <- data.frame(
count = rpois(n, lambda = 25),
effort = rgamma(n, shape = 12, rate = 1),
season = sample(c("summer", "winter"), n, replace = TRUE)
)
# Fit model
fit <- tratio(
count | effort ~ season,
data = df,
family = ratiod_poisson_gamma(),
mode = "hmc",
control = list(iter = 400, chains = 1, seed = 1)
)
# Compare CPUE between seasons
ratio_contrast(fit, ~ season)
#> tulpaRatio ratio contrasts
#> =====================
#>
#> Type: difference
#> Variable: season
#> Reference: summer
#>
#> contrast mean sd q2.5 q50 q97.5
#> winter vs summer -0.123931 0.08549462 -0.2502178 -0.1269074 0.08390861
#> prob_positive
#> 0.08
# Ratio of ratios (multiplicative comparison)
ratio_contrast(fit, ~ season, type = "ratio")
#> tulpaRatio ratio contrasts
#> =====================
#>
#> Type: ratio
#> Variable: season
#> Reference: summer
#>
#> contrast mean sd q2.5 q50 q97.5 prob_positive
#> winter vs summer 0.8866986 0.0773782 0.7786313 0.8808152 1.08753 1
# }