predictive_error.varstan: Out-of-sample predictive errors

Description Usage Arguments Value Note See Also

View source: R/predictive_error.R

Description

This is a convenience function for computing y - yh The method for stanreg objects calls posterior_predict internally, where as the method accepts the data.frame returned by posterior_predict as input and can be used to avoid multiple calls to posterior_predict.

Usage

1
2
3
4
5
6
7
8
9
## S3 method for class 'varstan'
predictive_error(
  object,
  newdata = NULL,
  xreg = NULL,
  draws = 1000,
  seed = NULL,
  ...
)

Arguments

object

Either a fitted model object returned by one of the rstanarm modeling functions (a stanreg object) or, for the "ppd" method, a matrix of draws from the posterior predictive distribution returned by posterior_predict.

newdata

An array with the newdata vector.

xreg

Optional, a numerical matrix of external regressors, which must have the same number of rows as ts. It should not be a data frame.

draws, seed

Optional arguments passed to posterior_predict. Please see the Note section below if newdata will be specified.

...

Further arguments passed to predictive_error.

Value

A draws by nrow(newdata) data.frame.

Note

If object is a varstan object of a varma model then newdata has to be a matrix with number of cols as the dimension of the time series and number of rows as the number new elements.

If object is a posterior_predict data.frame, then the length of newdata has to be equal to the ncol of object.

If object is a posterior_predict data.frame, for a varma model, then the dimension product of newdata matrix has to be equal to the ncol of object.

See Also

posterior_predict function from rstanarm package, to draw from the posterior predictive distribution without computing predictive errors.


bayesforecast documentation built on June 17, 2021, 5:14 p.m.