Forecasting in R
Rob J. Hyndman
Professor of Statistics at Monash University
training <- window(oil, end = 2003)
test <- window(oil, start = 2004)
fc <- naive(training, h = 10)
autoplot(fc) + autolayer(test, series = "Test data")
Compute accuracy using forecast errors on test data
Accuracy measure | Calculation |
---|---|
Mean absolute error | $\text{MAE} = avg(\mid e_t \mid)$ |
Mean squared error | $\text{MSE} = avg(e_t^2)$ |
Mean absolute percentage error | $\text{MAPE} = 100 \times avg(\mid \frac{e_t}{y_t} \mid )$ |
Mean absolute scaled error | $\text{MASE} = \frac{\text{MAE}}{Q}$ where $Q$ is a scaling constant |
accuracy(fc, test)
ME RMSE MAE MPE MAPE MASE ACF1 Theil's U
Training set 9.874 52.56 39.43 2.507 12.571 1.0000 0.1802 NA
Test set 21.602 35.10 29.98 3.964 5.778 0.7603 0.4030 1.185
Forecasting in R