| accuracy.cvforecast | R Documentation |
Return a range of summary measures of the out-of-sample forecast accuracy.
If x is given, the function also measures the test set forecast
accuracy. If x is not given, the function only produces accuracy
measures on the validation set.
## S3 method for class 'cvforecast'
accuracy(
object,
x,
CV = TRUE,
period = NULL,
measures = interval_measures,
byhorizon = FALSE,
...
)
## S3 method for class 'cpforecast'
accuracy(object, ...)
object |
An object of class |
x |
An optional numerical vector containing the actual values of the
same length as |
CV |
If |
period |
The seasonal period of the data. Defaults to |
measures |
A list of accuracy measure functions to compute (such as
point_measures or interval_measures). Defaults to
|
byhorizon |
If |
... |
Additional arguments depending on the specific measure. |
The measures calculated are:
ME: Mean Error
MAE: Mean Absolute Error
MSE: Mean Squared Error
RMSE: Root Mean Squared Error
MPE: Mean Percentage Error
MAPE: Mean Absolute Percentage Error
MASE: Mean Absolute Scaled Error
RMSSE: Root Mean Squared Scaled Error
Winkler: Winkler Score
MSIS: Mean Scaled Interval Score
A matrix giving mean out-of-sample forecast accuracy measures.
point_measures and interval_measures
for the measures that can be supplied through measures.
Other evaluation functions:
coverage(),
width()
# Simulate time series from an AR(2) model
library(forecast)
set.seed(1)
series <- arima.sim(n = 200, list(ar = c(0.8, -0.5)), sd = sqrt(1))
# Cross-validation forecasting with a rolling window
far2 <- function(x, h, level) {
Arima(x, order = c(2, 0, 0)) |>
forecast(h = h, level)
}
fc <- cvforecast(series, forecastfun = far2, h = 3, level = 95, window = 50)
# Out-of-sample forecast accuracy on validation set
accuracy(fc, measures = point_measures, byhorizon = TRUE)
accuracy(fc, measures = interval_measures, level = 95, byhorizon = TRUE)
# Accuracy of conformal prediction intervals
scpfc <- conformal(fc, method = "scp", ncal = 50, rolling = TRUE)
accuracy(scpfc, measures = interval_measures, level = 95,
byhorizon = TRUE)
# Out-of-sample forecast accuracy on test set
accuracy(fc, x = c(1, 0.5, 0), measures = interval_measures,
CV = FALSE, level = 95, byhorizon = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.