pp_check.mvgam {mvgam} | R Documentation |
Posterior Predictive Checks for mvgam
Objects
Description
Perform posterior predictive checks with the help of the bayesplot package.
Usage
## S3 method for class 'mvgam'
pp_check(
object,
type,
ndraws = NULL,
prefix = c("ppc", "ppd"),
group = NULL,
x = NULL,
newdata = NULL,
...
)
Arguments
object |
An object of class |
type |
Type of the ppc plot as given by a character string.
See |
ndraws |
Positive integer indicating how many
posterior draws should be used.
If |
prefix |
The prefix of the bayesplot function to be applied. Either '"ppc"' (posterior predictive check; the default) or '"ppd"' (posterior predictive distribution), the latter being the same as the former except that the observed data is not shown for '"ppd"'. |
group |
Optional name of a factor variable in the model
by which to stratify the ppc plot. This argument is required for
ppc |
x |
Optional name of a variable in the model.
Only used for ppc types having an |
newdata |
Optional |
... |
Further arguments passed to |
Details
For a detailed explanation of each of the ppc functions,
see the PPC
documentation of the bayesplot
package.
Value
A ggplot object that can be further customized using the ggplot2 package.
Author(s)
Nicholas J Clark
See Also
Examples
## Not run:
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,
burnin = 300,
samples = 300)
# 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)
# Custom functions accepted
prop_zero <- function(x) mean(x == 0)
pp_check(mod, type = "stat", stat = "prop_zero")
pp_check(mod, type = "stat_grouped",
stat = "prop_zero",
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")
## End(Not run)