0
$\begingroup$

I am using the forecast package in R to do ARIMA forecasting with auto.arima() function by Professor Hyndman.

I have 27 months of sales data (June 2014 to August 2016), I'm using the first 21 months as training set, and the rest 6 months as test set.

dataset <- c(380075, 367137, 320548, 290192, 256514, 365335, 356847, 287760, 378703, 415378, 331637, 228744, 407655, 496475, 340695, 410041, 725069, 594173, 614646, 530843, 565057, 487604, 565945, 410603, 405337, 283004, 211718) 
datasets = ts(dataset, start=c(2014,6), frequency=12)
trainsets <- window(datasets, end=time(datasets)[length(dataset)-6])
testsets <- window(datasets, start=time(datasets)[length(dataset)-5])
fit <- auto.arima(trainsets, ic='aic', D=1, seasonal=TRUE, approximation=FALSE,trace=TRUE, stepwise=FALSE, allowdrift=FALSE)
WA <- forecast(fit, 6)

And I got the return

> fit
Series: trainsets 
ARIMA(1,0,0)(0,1,0)[12]                    

Coefficients:
         ar1
      0.7148
s.e.  0.1989

sigma^2 estimated as 2.489e+10:  log likelihood=-120.32
AIC=244.63   AICc=246.63   BIC=245.03

> WA

Point          Forecast     Lo 80    Hi 80      Lo 95    Hi 95
Mar 2016       548576.1 346405.21 750747.0  239382.42 857769.8
Apr 2016       426841.5 178337.38 675345.5   46787.27 806895.6
May 2016       296792.2  27678.71 565905.7 -114781.35 708365.7
Jun 2016       456293.0 177237.44 735348.6   29514.34 883071.7
Jul 2016       531239.4 247238.93 815239.9   96898.14 965580.7
Aug 2016       365543.2  79049.34 652037.0  -72611.33 803697.7

I tried to do the manual calculation to understand the output, so because I have ARIMA(1,0,0)(0,1,0)[12]

So I expect the calculation to be

$$\hat{Y_t}(1) = \mu + \phi*(Y_{t-1} - Y_{t-2}) + Y_{t-12}$$

I think I can leave the $\mu$ = 0

So, for the March 2016 with the forecast of 548576.1, I calculate

$$\hat{Y_t}(MARCH2016) = 0 + 0.7148*(FEB2016 - JAN2016) + MARCH2015$$ $$\hat{Y_t}(MARCH2016) = 0 + 0.7148*(565057 - 530843) + 415378$$ $$\hat{Y_t}(MARCH2016) = 589513.1672$$

Question : What makes my calculation doesn't meet the correct forecasting? Can you please suggest me the right way to calculate the function?

Thank you.

$\endgroup$
2
  • $\begingroup$ I don't think you got the model equation right. The model is (omitting the intercept) $x_t=\varphi_1 x_{t-1} + \varepsilon_t$ where $x_t=(y_t-y_{t-12})$. Insert the latter expression of $x$ into the first equation, and you will get something different than you have now. $\endgroup$ Commented May 3, 2017 at 14:10
  • $\begingroup$ Hello, thank you for your reply. I tried to calculate the way you suggest me, but I think I got lost and needs to be clear. In your formula, what does Xt, Yt, and Et actually means? What I got is, Et for error term (but I don't know if there's exist in my ARIMA, so I leave it 0), Xt forecasted value?, and Yt is my actual sales? Or I'm getting wrong here? Thanks. @RichardHardy $\endgroup$ Commented May 3, 2017 at 14:30

1 Answer 1

2
$\begingroup$

The model is $$ x_t=\varphi_1 x_{t−1}+\varepsilon_t $$ where $x_t=(y_t−y_{t−12})$. Insert the latter expression into the equation above to get $$ (y_t - y_{t-12}) = \varphi_1 (y_{t-1} - y_{t-13}) + \varepsilon_t, $$ thus $$ y_t = y_{t-12} + \varphi_1 (y_{t-1} - y_{t-13}) + \varepsilon_t. $$ When you forecast one step ahead, you get \begin{aligned} \hat y_{t+1|t} &= y_{t-12+1} + \varphi_1(y_{t-1+1} - y_{t-13+1}) + \hat\varepsilon_{t+1|t} \\ &= y_{t-11} + \varphi_1(y_{t} - y_{t-12}) + 0 \\ &= y_{t-11} + \varphi_1(y_{t} - y_{t-12}). \\ \end{aligned}

$\endgroup$
7
  • $\begingroup$ Thank you for your brief explanation, I have tried your suggestion there, and the answer become more close to the auto.arima forecasting result. Here is the result I got : For my March 2016 forecast, I calculate with your suggested equation as follow : $$ \hat{y}_t(MARCH2016) = \{y}_t(MARCH2015) + 0.7148 * \{y}_t(FEB2016) - \{y}_t(FEB2015) $$ $$ = 415378 + 0.7148 * ( 565057 - 378703 ) $$ $$ = 548583.8392 $$ Expected : 548576.1 There was a little difference with the expected output in WA$mean variable, was I wrong in calculating the quotation? Thank you @richard $\endgroup$ Commented May 3, 2017 at 16:23
  • $\begingroup$ Can it be a rounding problem or something? Maybe try using coef(fit)[1] instead of 0.7148 in your manual calculation. $\endgroup$ Commented May 3, 2017 at 16:25
  • $\begingroup$ Oh yea! Finally, it is actually a rounding problem on the coefficient, I just recheck by calling the function coef(fit) and found different result of my ar1, which is 0.7147584, not 0.7148 as displayed on the fit calls. Thank you so much Richard. $\endgroup$ Commented May 3, 2017 at 16:30
  • $\begingroup$ @ErvanSanjaya, I am glad to have been able to help. $\endgroup$ Commented May 3, 2017 at 16:31
  • $\begingroup$ Richard, I have another question, actually I don't really get it how you can say "where xt=(yt−yt−12)xt = (yt−yt−12). Insert the latter ..." At this point, I'm kinda confused to fit each model to calculate manually. I have this following model to be manually calculated : ARIMA(1,0,0)(0,1,0) ARIMA(3,1,0)(0,1,0) ARIMA(1,1,0)(0,1,0) ARIMA(0,0,1)(0,1,0) ARIMA(2,0,0)(0,1,0) ARIMA(3,0,0)(0,1,0) ARIMA(2,1,0)(0,1,0) ARIMA(4,1,0)(0,1,0) ARIMA(2,1,0)(0,1,0) Can you give me solution on how to build the quotation to each model with a simple 'how-to'? Thanks. $\endgroup$ Commented May 3, 2017 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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