predictive_error.varstan {bayesforecast} | R Documentation |
Out-of-sample predictive errors
Description
This is a convenience function for computing y - y_{h}
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
## 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 |
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 |
... |
Further arguments passed to |
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.