I have read the questions about the ARIMA and ARMA prediction here and here, and also here.

I'd like to make an one-step ahead forecast in-sample with the ARIMA(p=1,d=1,q=0) model. I have used the forecast packages:

  mydata1 <- runif(n, 9000, 10000)
  fit1<-Arima(mydata1[1:(n-1)], order=c(1,1,0))
  forecast(fit1, h=1)$mean[1] 
  # 9850.593

Then I have tried to use the predict() function

  predict(fit1, n.ahead=1)$pred[1]
  # 9850.593

The reasults are equal. The ARIMA(1,1,0) model has only one coefficient ar1:

  # ar1 
  # -0.4896545 

I have tried to write the one-step ahead prediction: $$\hat Y_{n|n-1} = \hat \mu + \hat{ar_1} \cdot (Y_{n-1} - \hat \mu).$$

and then make the calculation in R:

mean(mydata1[n-1]) + coef(fit1)[1] * (mydata1[n-1] - mean(mydata1[n-1]))
#     ar1 
# 9761.974 

The manual result is 9761.974 and it is not equal to 9850.593. I think my mistake in the formula because I should use the first difference of time series (d=1) but not the original time series.

Question. Could anyone guide me in the manual calculation?


The ARIMA(1,1,0) model is defined as follows: $$ (y_t - y_{t-1}) = \phi (y_{t-1} - y_{t-2}) + \varepsilon_t \,, \quad \varepsilon_t \sim NID(0, \sigma^2) \,. $$

The one-step ahead forecast is then (forwarding the above expression one period ahead):

$$ \hat{y}_{t+1} = \hat{y}_t + \phi (\hat{y}_t - \hat{y}_{t-1}) + \underbrace{E(\varepsilon_{t+1})}_{=0} \,. $$

In your example:

# 9850.593 
# agreeing with
predict(fit1, n.ahead=1)$pred[1]
# [1] 9850.593
| cite | improve this answer | |
  • $\begingroup$ The above was super helpful! what will it be if exogenous variables were in the mix? $\endgroup$ – Shoaibkhanz Oct 20 '19 at 19:23
  • $\begingroup$ @Shoaibkhanz You may be interested in this and this post. $\endgroup$ – javlacalle Oct 22 '19 at 17:49

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.