# \donttest{
simdat <- sim_mvgam(seasonality = "hierarchical")
mod <- mvgam(
y ~ series +
s(season, bs = "cc", k = 6) +
s(season, series, bs = "fs", k = 4),
data = simdat$data_train,
chains = 2,
silent = 2
)
# Use pp_check(mod, type = "xyz") for a list of available plot types
# Default is a density overlay for all observations
pp_check(mod)
# Rootograms particularly useful for count data
pp_check(mod, type = "rootogram")
# Grouping plots by series is useful
pp_check(mod,
type = "bars_grouped",
group = "series", ndraws = 50
)
pp_check(mod,
type = "ecdf_overlay_grouped",
group = "series", ndraws = 50
)
pp_check(mod,
type = "stat_freqpoly_grouped",
group = "series", ndraws = 50
)
# Several types can be used to plot distributions of randomized
# quantile residuals
pp_check(
object = mod,
x = "season",
type = "resid_ribbon"
)
pp_check(
object = mod,
x = "season",
group = "series",
type = "resid_ribbon_grouped"
)
pp_check(mod,
ndraws = 5,
type = "resid_hist_grouped",
group = "series"
)
# Custom functions accepted
pp_check(mod, type = "stat", stat = function(x) mean(x == 0))
pp_check(mod,
type = "stat_grouped",
stat = function(x) mean(x == 0),
group = "series"
)
# Some functions accept covariates to set the x-axes
pp_check(mod,
x = "season",
type = "ribbon_grouped",
prob = 0.5,
prob_outer = 0.8,
group = "series"
)
# Many plots can be made without the observed data
pp_check(mod, prefix = "ppd")
# }
Run the code above in your browser using DataLab