Extract posterior distributions of temporally-varying coefficients (TVCs) from a fitted ratio model with TVC specification.
Value
A ratiod_tvc_posterior object containing:
draws: Array of posterior draws (draws x times x terms)time_levels: Time point labelsterm_names: Names of TVC terms
Examples
if (FALSE) { # \dontrun{
# Generate synthetic data (not run - TVC experimental)
set.seed(160)
df <- data.frame(
year = rep(2015:2024, each = 5),
x = rnorm(50),
count = rpois(50, lambda = 18),
effort = rgamma(50, shape = 3.5, rate = 1)
)
# Fit model with TVC
fit <- tratio(
count | effort ~ x,
data = df,
family = ratiod_poisson_gamma(),
tvc = temporal_tvc("year", terms = c(1, 2)),
mode = "hmc",
control = list(iter = 200, warmup = 100, chains = 1)
)
# Extract TVC posteriors
tvc_post <- tvc(fit)
summary(tvc_post)
# Plot temporal evolution
plot(tvc_post, "x")
} # }