Plot posterior (default) or prior (prior = TRUE) predictive checks. This is a convenience wrapper
around the bayesplot::ppc_*() methods. See
prior predictive checks for an example.
Usage
# S3 method for class 'mcpfit'
pp_check(
object,
type = "dens_overlay",
facet_by = NULL,
newdata = NULL,
prior = FALSE,
group_effects = TRUE,
arma = "replicate",
ndraws = 100,
nsamples = lifecycle::deprecated(),
varying = lifecycle::deprecated(),
...
)Arguments
- object
An
mcpfitobject.- type
String specifying the type of plot. See
bayesplot::available_ppc()for available plot types, omitting the"ppc_"prefix (e.g.,"dens_overlay","ribbon","intervals").- facet_by
Name of a grouping column used by group-level effects.
- newdata
A
tibbleor adata.framecontaining predictors in the model.If
NULL(default), the original data is used.Grouping factors must only contain levels from the fitted data. Use
group_effects = FALSEto predict without group-level effects, e.g., for new groups.For models with
ar()orma():fitted(),residuals(),log_lik(), andpredict()condition on the response history by default, sonewdatamust include the response. Forfitted(),predict(), andresiduals(), missing response histories are supported only in the original fitted data, using retained posterior imputations as histories. Predictions are fresh response draws, including at missing rows. Witharma = "replicate",predict()andposterior_predict()generate fresh response series recursively, so theirnewdataneed only contain predictors and required response auxiliaries.log_lik()is unavailable when a missing response enters a later observed history.For models with
y | weights(): Require the weights column except forfitted()andpredict().
- prior
Logical. Evaluate prior draws (
TRUE) instead of posterior draws (FALSE, default). The selected draws must be available; prior-only fits requireprior = TRUE.- group_effects
Group-level effects to include. One of:
TRUEAll group-level deviations.FALSEorNANo group-level deviations, i.e., population-level predictions. Likere_formula = NAin{brms}."cp"or"predictor": All group-level deviations belonging to that part of the model.Character vector of group-level parameter names, e.g.,
c("cp_1_id", "x_2_id").*is a wildcard, e.g.,"state*_1_id"selects all levels of a factor and"*_id"selects all effects byid. See names usingranef(fit). Can be combined, e.g.,c("cp", "sigma_*").
- arma
How to include AR and MA effects.
TRUE: Condition on the observed response history, i.e., one-step-ahead evaluation of the GARMA residual recurrence. Requires the response variable innewdata.FALSE: Disregard AR and MA effects. Forfamily = gaussian(),predict()uses onlysigmafor residuals."replicate": Generate fresh response series recursively instead of conditioning on the observed responses. Only for predictions:predict(),posterior_predict(), andpp_check()(where it is the default). Applies equally to prior and posterior draws.
For posterior evaluation of the original data, retained JAGS imputations supply missing GARMA histories. In models with group-level effects, this currently requires all such effects (
group_effects = TRUE).- ndraws
Integer or
NULL. Number of posterior draws to return/summarise.NULLmeans "all". More draws trade speed for accuracy.- nsamples
Deprecated. Use
ndrawsinstead.- varying
Deprecated. Use
group_effectsinstead.- ...
Further arguments passed to
bayesplot::ppc_type(y, yrep, ...)
Details
Missing responses are omitted from the observed-data check. LOO predictive
checks use posterior draws and the original fitted data, so they do not
support prior = TRUE or newdata. For GARMA models, they default to arma = TRUE
to match the one-step-ahead log-likelihood used for the LOO weights.
Author
Jonas Kristoffer Lindeløv jonas@lindeloev.dk


