
tsCV
computes the forecast errors obtained by applying
forecastfunction
to subsets of the time series y
using a
rolling forecast origin.
tsCV(y, forecastfunction, h = 1, ...)
Univariate time series
Function to return an object of class
forecast
. Its first argument must be a univariate time series, and it
must have an argument h
for the forecast horizon.
Forecast horizon
Other arguments are passed to forecastfunction
.
Numerical time series object containing the forecast errors.
Let y
contain the time series forecastfunction
is applied successively to the time series
forecastfunction
to very short time
series.
# NOT RUN {
#Fit an AR(2) model to each subset
far2 <- function(x, h){forecast(Arima(x, order=c(2,0,0)), h=h)}
e <- tsCV(lynx, far2, h=1)
# }
Run the code above in your browser using DataLab