Solved – Forecast models of differenced/undifferenced data

forecastingrstationarity

I am building different forecasting models on my time series (which is not stationary). Some models require stationarity, others don't. My goal is to test a few models on a training set, compare the forecasts to the observed values (the test set), and see which model was the most accurate in forecasting.

However, as I am differencing my data for some models only, when I'm trying to compare the forecasts I obviously end up with different type of output (differenced vs. undifferenced). How should do we usually proceed at this point? Is there a way to revert back my forecasts to "undifferenced" data (in R)?

In know that with ARIMA, it's easy as I can simply ask ARIMA to difference it for me. But when I difference manually using diff()before forecasting using ETS(), then it's a different story. I only difference once by the way.

Thank you!

Best Answer

You should compare your models on identical tasks. If your goal is to forecast levels, then each model must produce a forecast of the level to compare with the others. If one of your models naturally produces a forecast of some transformation of the data, you have to invert it to do this comparison.

If the transformation is differencing, the opposite transformation is the cumulative sum. You can see this by the telescoping sum:

$$\sum_{i=1}^t (X_i - X_{i-1}) = X_t - X_{t-1} + X_{t-1} - \ldots - X_1 + X_1 - X_0 = X_t - X_0$$

So then

$$ X_t = X_0 + \sum_{i=1}^t \Delta X_i$$

Similarly, the level forecast for $t+h$ made at $t$ is:

$$ \hat{X}_{t+h} = X_t + \sum_{i=1}^h \Delta \hat{X}_{t+i}$$

In R, you can do this with the function diffinv. You have to pass in the very last point of the data as the argument xi.