% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plotPredictive.R
\name{plot_ppredictive}
\alias{plot_ppredictive}
\title{Plot samples drawn from the posterior predictive density.}
\usage{
plot_ppredictive(stanfit, type = "", r = NULL, subset = NULL,
  chain = 1, fun = NULL, fun1 = NULL, fun2 = NULL,
  boxplotControl = NULL, cumulativeControl = NULL,
  densityControl = NULL, funControl = NULL, fun1Control = NULL,
  fun2Control = NULL, ksControl = NULL, klControl = NULL,
  main = NULL)
}
\arguments{
\item{stanfit}{An object returned by either \code{\link{fit}} or \code{\link{draw_samples}}.}

\item{type}{An optional vector of character strings with the names of the analysis to include in the plot. These may be \emph{density} (kernel density curves of the observation variable), \emph{cumulative} (kernel cumulative density curves of the observation variable), \emph{boxplot} (boxplots of the observation variable), \emph{histogram} (histogram of the values returned by \emph{fun}), \emph{scatterplot} (scatterplot of the values returned by \emph{fun1} and \emph{fun2}), \emph{kl} (histogram of the empirical Kullback-Leibler divergence), \emph{ks} (histogram of the Kolmogorov-Smirnov statistic). All plots show the actual sample and many draws from the posterior predictive density. Note that more than one type may be plotted at the same time. It allows for partial matching. It defaults to none.}

\item{r}{An optional numeric vector with the numbers of the dimensions of the observation vector to be plotted. It defaults to plotting all variables.}

\item{subset}{An optional boolean vector indicating with TRUE which elements of the observation vector should be included in the analysis (some plots may become slow with large datasets). It defaults to NULL, meaning all the sample units.}

\item{chain}{An optional integer number between 1 and the number of chains M. Only the samples generated by the selected chain are considered. It defaults to the first chain.}

\item{fun}{An optional function summarizing the whole sample into a single value (e.g. \code{\link{median}}). This function is applied ot each sample (actual and generated) and the values returned are plotted in the histogram.}

\item{fun1}{An optional function summarizing the whole sample into a single value (e.g. \code{\link{mean}}). This function is applied ot each sample (actual and generated) and the values returned are plotted in the horizontal axis of the scatterplot.}

\item{fun2}{An optional function summarizing the whole sample into a single value (e.g. \code{\link{sd}}). This function is applied ot each sample (actual and generated) and the values returned are plotted in the vertical axis of the scatterplot.}

\item{boxplotControl}{Arguments to be passed to \code{\link{boxplot}} if the argument \emph{type} includes "boxplot".}

\item{cumulativeControl}{Arguments to be passed to \code{\link{quantile}} if the argument \emph{type} includes "cumulative" (e.g. use `probs` to set a range if the default is innapropiate).}

\item{densityControl}{Arguments to be passed to \code{\link{density}} if the argument \emph{type} includes "density".}

\item{funControl}{Arguments to be passed to `fun` if the argument \emph{type} includes "histogram".}

\item{fun1Control}{Arguments to be passed to `fun1` if the argument \emph{type} includes "scatterplot".}

\item{fun2Control}{Arguments to be passed to `fun2` if the argument \emph{type} includes "scatterplot".}

\item{ksControl}{Arguments to be passed to \code{\link{ks.test}} if the argument \emph{type} includes "ks".}

\item{klControl}{Arguments to compute the empirical Kullback-Leibler divergence if the argument \emph{type} includes "kl". It may include two-sized vectors with the lower and upper bounds of the discretization range (`yRange` and `yPredRange`) and the number of bins (`yNBins` and `yPredNBins`).}

\item{main}{An optional character string with the overall title for the plot.}
}
\description{
When the observed random variable is multivariate, one individual plot per dimension will be drawn (i.e. the analysis will be carried out marginally). As with all visualizations from this package, colors are fully customizable via a \code{\link{theme}}. Note that this method is only available for full Bayesian estimation run via Markov-chain Monte Carlo.
}
\note{
If the user was surprised to find the Kolmogorov-Smirnov statistic in a Bayesian software, simply note that we use it as a measure of similarity between two samples from continuous distributions. Data analysis and modeling decissions do not rely on hypothesis testing.
}
\examples{
\dontrun{
plot_ppredictive(
  myFit,
  type = c("density", "cumulative", "boxplot",
           "histogram", "scatterplot", "ks"),
  fun = mean, fun1 = mean, fun2 = sd
)

plot_ppredictive(
  myFit,
  type = c("density", "cumulative", "ks", "kl"),
  klControl = list(yNBins = 20, yPredNBins = 20)
)
}
}
\seealso{
Other visualization functions: \code{\link{get_current_theme}},
  \code{\link{get_default_theme}},
  \code{\link{modify_theme_entry}},
  \code{\link{plot_series}},
  \code{\link{plot_state_probability}}, \code{\link{theme}}
}
\concept{visualization functions}
