Extract posterior distributions of temporally-varying coefficients (TVCs) from a fitted tulpa model with TVC specification.
Value
A tulpa_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
# \donttest{
set.seed(160)
n_t <- 10L; reps <- 5L
walk <- cumsum(rnorm(n_t, 0, 0.35)); walk <- walk - mean(walk)
year <- rep(seq_len(n_t), each = reps)
df <- data.frame(year = year, x = rnorm(length(year)))
df$count <- rpois(nrow(df), exp(0.3 + (0.5 + walk[year]) * df$x))
# The slope on `x` walks in time; TVC is exact-mode only.
fit <- tulpa(
count ~ x,
data = df,
family = "poisson",
temporal = temporal_tvc("year", terms = ~ x - 1, structure = "rw1"),
mode = "exact",
control = list(n_iter = 200L, n_warmup = 100L, seed = 1L)
)
tvc_post <- tvc(fit)
summary(tvc_post)
plot(tvc_post, "x")
# }