| predictive_error {rstantools} | R Documentation |
Generic function and default method for computing predictive errors
y - yrep (in-sample, for observed y) or
y - ytilde (out-of-sample, for new or held-out y).
See predictive_error.stanreg in the
rstanarm package for an example.
predictive_error(object, ...) ## Default S3 method: predictive_error(object, y, ...)
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 |
predictive_error methods should return a D by N
matrix, where D is the number of draws from the posterior predictive
distribution and N 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.
The guidelines for developers of R packages interfacing with Stan, a
copy of which can be found in the package vignettes. See
browseVignettes("rstantools") or vignette(package =
"rstantools"). The document is also available online at the
rstantools page on the
CRAN
website.
# default method
y <- rnorm(10)
ypred <- matrix(rnorm(500), 50, 10)
predictive_error(ypred, y)
# Also see help("predictive_error", package = "rstanarm")