View source: R/diagnostic_plots.R
qq_postpred | R Documentation |
Produces a quantile-quantile plot, calculated from the quantiles of a vector of data (most likely a time series), with respect to the matrix of associated posterior predictive distributions.
While not an omnibus posterior predictive check, this plot can be useful for detecting an overparameterized model, or else improper specification of observation error. Like a traditional Q-Q plot, a well-specified model will have points that lie close to the x=y line. In the case of this function, an overparametrized model will typically produce a plot with a much shallower slope, possibly with many associated posterior predictive quantiles close to 0.5.
It should be noted that this function will only produce meaningful results with a vector of data, as opposed to a single value.
The posterior predictive distribution can be specified in two possible ways:
either a single output object from jagsUI
with an associated parameter
name, or as a matrix or data.frame
of posterior samples.
qq_postpred(ypp, y, p = NULL, add = FALSE, ...)
ypp |
Either a matrix or |
y |
The associated data vector |
p |
A character name, if a |
add |
Whether to add the plot to an existing plot. Defaults to |
... |
Optional plotting arguments |
NULL
This function assumes the existence of a matrix of posterior predictive samples corresponding to a data vector, the construction of which must be left to the user. This can be accomplished within JAGS, or using appropriate simulation from the posterior samples.
Matt Tyers
ts_postpred, plot_postpred, check_Rhat, check_neff, traceworstRhat, plotRhats
# first, a quick look at the example data...
str(SS_data)
str(SS_out$sims.list$ypp)
# plotting the example posterior predictive distribution with the data
# points overlayed. Note the overdispersion in the posterior predictive.
caterpillar(SS_out, p="ypp")
points(SS_data$y)
# using a jagsUI object as ypp input
qq_postpred(ypp=SS_out, p="ypp", y=SS_data$y)
# using a matrix as ypp input
qq_postpred(ypp=SS_out$sims.list$ypp, y=SS_data$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.