predictive_error {rstantools}R Documentation

Generic function and default method for predictive errors

Description

Generic function and default method for computing predictive errors yyrepy - y^{rep} (in-sample, for observed yy) or yy~y - \tilde{y} (out-of-sample, for new or held-out yy). See predictive_error.stanreg() in the rstanarm package for an example.

Usage

predictive_error(object, ...)

## Default S3 method:
predictive_error(object, y, ...)

Arguments

object

The object to use.

...

Arguments passed to methods. See the methods in the rstanarm package for examples.

y

For the default method, a vector of y values the same length as the number of columns in the matrix used as object.

Value

predictive_error() methods should return a DD by NN matrix, where DD is the number of draws from the posterior predictive distribution and NN is the number of data points being predicted per draw.

The default method just takes object to be a matrix and y to be a vector.

See Also

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")


[Package rstantools version 2.4.0 Index]