forecast_accuracy {OOS} | R Documentation |
Calculate forecast accuracy
Description
A function to calculate various loss functions, including MSE, RMSE, MAE, and MAPE.
Usage
forecast_accuracy(Data)
Arguments
Data |
data.frame: data frame of forecasts, model names, and dates |
Value
data.frame of numeric error results
Examples
# simple time series
A = c(1:100) + rnorm(100)
date = seq.Date(from = as.Date('2000-01-01'), by = 'month', length.out = 100)
Data = data.frame(date = date, A)
# run forecast_univariate
forecast.uni =
forecast_univariate(
Data = Data,
forecast.dates = tail(Data$date,10),
method = c('naive','auto.arima', 'ets'),
horizon = 1,
recursive = FALSE,
freq = 'month')
forecasts =
dplyr::left_join(
forecast.uni,
data.frame(date, observed = A),
by = 'date'
)
# forecast accuracy
forecast.accuracy = forecast_accuracy(forecasts)
[Package OOS version 1.0.0 Index]