ts_postpred {jagshelper} | R Documentation |
Time series plot of centered posterior predictive distribution
Description
Produces a plot of centered posterior predictive distributions associated with a vector of data (most likely a time series), defined as the difference between posterior predictive and posterior predictive median.
Also overlays the posterior predictive residuals, defined as the differences between data values and their respective posterior predictive medians.
While not an omnibus posterior predictive check, this plot can be useful for detecting an overparameterized model, or else improper specification of observation error.
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.
Usage
ts_postpred(
ypp,
y,
p = NULL,
x = NULL,
lines = FALSE,
pch = 1,
pointcol = 1,
transform = c("none", "exp", "expit"),
...
)
Arguments
ypp |
Either a matrix or |
y |
The associated data vector |
p |
A character name, if a |
x |
The time measurements associated with time series |
lines |
Whether to add a line linking data time series points. Defaults to |
pch |
Plotting character for points, which will accept a vector input.
See points. Defaults to |
pointcol |
Plotting color for points. Defaults to |
transform |
Should the y-axis be (back)transformed? Options are |
... |
Additional arguments to envelope |
Value
NULL
Note
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.
Author(s)
Matt Tyers
See Also
qq_postpred, plot_postpred, check_Rhat, check_neff, traceworstRhat, plotRhats
Examples
# 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
ts_postpred(ypp=SS_out, p="ypp", y=SS_data$y)
# using a matrix as ypp input
ts_postpred(ypp=SS_out$sims.list$ypp, y=SS_data$y)
# exp transformation
ts_postpred(ypp=SS_out, p="ypp", y=SS_data$y, transform="exp")
ts_postpred(ypp=SS_out, p="ypp", y=SS_data$y, transform="exp", log="y")