% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predictive_error.R
\name{predictive_error}
\alias{predictive_error}
\alias{predictive_error.default}
\title{Generic function and default method for predictive errors}
\usage{
predictive_error(object, ...)

\method{predictive_error}{default}(object, y, ...)
}
\arguments{
\item{object}{The object to use.}

\item{...}{Arguments passed to methods. See the methods in the \pkg{rstanarm}
package for examples.}

\item{y}{For the default method, a vector of \code{y} values the same length as
the number of columns in the matrix used as \code{object}.}
}
\value{
\code{predictive_error()} methods should return a \eqn{D} by \eqn{N}
matrix, where \eqn{D} is the number of draws from the posterior predictive
distribution and \eqn{N} is the number of data points being predicted per
draw.

The default method just takes \code{object} to be a matrix and \code{y} to be a
vector.
}
\description{
Generic function and default method for computing predictive errors
\eqn{y - y^{rep}}{y - yrep} (in-sample, for observed \eqn{y}) or
\eqn{y - \tilde{y}}{y - ytilde} (out-of-sample, for new or held-out \eqn{y}).
See \href{https://mc-stan.org/rstanarm/reference/predictive_error.stanreg.html}{predictive_error.stanreg()}
in the \pkg{rstanarm} package for an example.
}
\examples{
# default method
y <- rnorm(10)
ypred <- matrix(rnorm(500), 50, 10)
pred_errors <- predictive_error(ypred, y)
dim(pred_errors)
head(pred_errors)

# Also see help("predictive_error", package = "rstanarm")

}
\seealso{
\itemize{
\item The \pkg{rstanarm} package (\href{https://mc-stan.org/rstanarm/}{mc-stan.org/rstanarm})
for example methods
(\href{https://CRAN.R-project.org/package=rstanarm}{CRAN},
\href{https://github.com/stan-dev/rstanarm}{GitHub}).
}

\itemize{
\item Guidelines and recommendations for developers of \R packages
interfacing with Stan and a demonstration getting a simple package working
can be found in the vignettes included with \pkg{rstantools} and at
\href{https://mc-stan.org/rstantools/articles/}{mc-stan.org/rstantools/articles}.
}
}
