2
$\begingroup$

I am fairly new to R so my data manipulation experience isn't as strong as it is with other software packages. I have been primarily using the high level functions that others have written. The forecast package written by Hyndman is fantastic and I have also enjoyed reading his book.

What I am struggling with is how to create ARIMA fitted values that are greater than one step forward. The current function will painlessly create fitted values for a one time period projection on historical data. You can use the accuracy function to determine RMSE, MAPE, MASE to test the accuracy of your modelling forecasts. However, I would like to variably test how well the forecast performs for different projections into the future.

For example, I am currently working with weekly time series data and the current goal is to forecast one month into the future. The fitted values and accuracy function show how well my forecast would have performed if I were only projecting 1 week into the future instead of 4. Is there a quick and efficient way to select how many periods into the future we would like to estimate the accuracy for historical data?

Forgive me if I have missed a fundamental aspect of forecasting. I know that I can simply aggregate my weekly time series data into monthly data and then use my ARIMA model to forecast monthly instead of weekly periods. However, since I have multiple years of data, I am largely concerned with seasonality and it would be nice to see how the data ramps up in each week of the month (also would be nice to account for holidays that may affect weekly results). I also realize that I can simply forecast monthly data and then use cubic spline interpolation.

Thank you in advance!

$\endgroup$
1
$\begingroup$

You can tell the various forecast() functions, such as forecast.ets() or forecast.Arima() (note the capital A if you want to look at the help page) to forecast up to $h$ periods ahead by specifying the h parameter.

If you are then interested in accuracy over the entire holdout horizon, just feed this into accuracy. If you want to compare accuracy 1 period out against accuracy 12 periods out, just extract the relevant periods from the forecast (and the holdout actuals).

Here is an example, where I use the AirPassengers dataset, holding out the last 12 observations, fitting an automatic ARIMA model and assessing average accuracy over 12 months as well as accuracy 1 and 12 months ahead:

> library(forecast)
> 
> fcst <- forecast(auto.arima(AirPassengers[1:132]),h=12)
> accuracy(fcst$mean,AirPassengers[133:144])
               ME     RMSE     MAE       MPE     MAPE
Test set -15.3857 53.35746 45.6625 -4.632225 9.647511
> accuracy(fcst$mean[1],AirPassengers[133])
                ME     RMSE      MAE       MPE     MAPE
Test set -8.570209 8.570209 8.570209 -2.055206 2.055206
> accuracy(fcst$mean[12],AirPassengers[144])
                ME     RMSE      MAE       MPE     MAPE
Test set -38.26647 38.26647 38.26647 -8.857979 8.857979
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.