
Posterior predictive intervals on a fitted mvgam model
Source:R/brms_wrappers.mvgam.R
predictive_interval.mvgam.RdCentral quantile intervals of the draws posterior_predict.mvgam()
returns, one per observation.
Usage
# S3 method for class 'mvgam'
predictive_interval(object, prob = 0.9, ...)Arguments
- object
A fitted
mvgamobject.- prob
Numeric in
(0, 1). The probability mass each interval holds. Defaults to0.9.- ...
Arguments of
posterior_predict.mvgam(), such asnewdataorincl_autocor.
See also
posterior_interval.mvgam() gives intervals of parameters.
pp_check.mvgam() plots predictive draws against the data.
Other predictions:
conditional_effects.mvgam(),
conditional_smooths.mvgam(),
fitted.mvgam(),
hindcast(),
posterior_epred.mvgam(),
posterior_linpred.mvgam(),
posterior_predict.mvgam(),
posterior_smooths.mvgam(),
predict.mvgam(),
predictive_error.mvgam()
Examples
# \dontrun{
set.seed(13)
simdat <- sim_mvgam(family = poisson(), n_series = 1L,
n_timepoints = 120L, trend_model = AR())
mod <- mvgam(y ~ s(x, k = 5), trend_formula = ~ AR(p = 1),
data = simdat$data_train, family = poisson(),
chains = 2, silent = 2)
#> Warning: 8 of 2000 (0.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
# 90 percent intervals, one row per observation
intervals <- predictive_interval(mod)
head(intervals)
#> 5% 95%
#> [1,] 0 5
#> [2,] 6 20
#> [3,] 4 14
#> [4,] 4 15
#> [5,] 1 9
#> [6,] 2 13
# The share of observed counts the intervals cover
y <- simdat$data_train$y
mean(y >= intervals[, 1] & y <= intervals[, 2])
#> [1] 0.7777778
# Next: pp_check() plots the predictive draws against the data
# }