# Manually replicating an ARIMA forecast

I hate to ask this question but I am going insane and other links haven't solved this problem. I have a seasonal ARIMA with just over two years of weekly data ARIMA(0,1,1)(0,1,1)[52]. It's highly seasonal and this model fits well enough for initial forecasting. I'm using Rob Hyndman's forecast package and the Arima and forecast functions within it. However, I am providing the forecasts and the forecasting equation to a client. So far, so good.

However, when I write out the forecasting equation I get numbers close but not equal to the forecast. I have double-checked my equation (here) and cannot figure out what I'm doing wrong. Here are the numbers:

    Y_20_49 <- 791.7044   # One period back
Y_19_50 <- 516.0694   # One year ago
Y_19_49 <- 812.9433   # One year and one period ago

# Residuals acquired with sweep::augment();
# same as residuals(model)
resid_20_49 <- 1.048402e+01  # Residual one period ago
resid_19_50 <- -1.865834e+02 # Residual one year ago
resid_19_49 <- 2.784324e+01  # Residual one year and a period ago.

ma1  <- -0.8761              # MA1 coefficient from ARIMA
sma1 <- 1                    # SMA1 coef from ARIMA

# Manual = 274.6686
Manual <- Y_20_49 + Y_19_50 - Y_19_49 +
ma1 * resid_20_49 + sma1 * resid_19_50 +
(ma1 * sma1) * resid_19_49
Actual <- 334.4015           # Result from forecast(h = 1)


There's something obvious I'm missing but I'd appreciate any help. This model is not transformed but I have the same problem with another similar model that is logged.

UPDATE: The model results report only MA and SMA terms; no constants. Here is a picture of the summary(model) results:

UPDATE2: The manual calculations seem to work when the MA and SMA terms are not close to one (even around abs(0.88) seems OK). I cannot be certain if this is the case but this happened during my quest to reproduce the forecasts.

• Does the forecast package result include a constant term? Feb 4 '20 at 20:52
• Sadly no; see above. Feb 4 '20 at 21:20

For example a seasonal model of 12 looks like this .

Check your signs for the ma terms ... you have all positives ..... should be 2 positives and 1 negative .

I used AUTOBOX which has an option to present the model And the forecast in simple terms ( as you are trying to do ) . I used weekly data for 177 periods and HARDWIRED i.e specified a starting model and disabled estimation and/or model revision and obtained the following

I then captured the forecast coming from the model and obtained this result

I then selected this output option to present the model as a pure right-handside ...called rhside.txt presented here

If you wish to contact me offline I would be glad to share the data ….and the residuals from the model so that you could use them to investigate your enigma .

I don't really know how to attach a csv file to this answer and if I knew I would be happy to do just that.

Note that AUTOBOX presents the coefficients in the standard/classical way ….not in the negative as your software does.

• Unfortunately, when I use that equation I get an even worse answer. As I understand it (see here: rdocumentation.org/packages/stats/versions/3.6.2/topics/arima), R reports the MA coefficients as if they were all summed (hence the sums in the equation above). I thought since the MA1 term was negative it would work out. I've played around with switching the signs but luck. I am befuddled. I am using tried and true equations from the texts but the forecast() function (and the predict.Arima() functions all provide identical answers to one another but not to my manual calcs. Feb 5 '20 at 14:10
• post your data and I will run it through AUTOBOX which presents the model in the expanded form and I can look at it closely in order to help you. Feb 5 '20 at 16:20
• I appreciate the thought! Unfortunately, the raw data is proprietary client data and while it's improbable to hurt I'm not going to take the chance. As best I can figure (and I'm uncertain about it), the problem occurred when the SMA or MA coefficients were close to 1.The manual calculation using the formula you provided matched the forecast when the coefficients were abs(.88) or smaller. Feb 7 '20 at 18:19
• If you found my answer reasonable then upvote it accept it as this is a done deal. Feb 7 '20 at 19:14