Ive been implementing a little exercise to obtain the first 2 forecasting points of an AR(1) process. And i want to have the forecasting ponts using the three forms: Im folowing this pdf http://www.le.ac.uk/users/dsgp1/COURSES/BANKERS/BANKERS6.PDF

Difference Equation Forms, Moving Aerage Form and Auroregressive Form:

I did well for the first two forms:

x <- arima.sim(n=108, list(ar=0.5))
data.ts <- ts(x, start=c(1999,01), freq=12)
time = window(data.ts, start=c(1999,01),end=c(2007,12))
inflarima1 <- arima( x,order = c(1, 0, 0))

    #    ar1    intercept
    #0.4945659  0.2069526 
#Jan       Feb
#2008 0.1147776 0.1613660

FIRST FORM: Difference Equation Form

# c^= INTERCEPT*(1-phi) 
#h=1 -> yt+1 = c^ + phi*Yt 
0.2069526*(1-0.4945659) + 0.4945659*x[108]
#h=2 -> yt+1 = c^ + phi*Yt+1 = c^ + phi*[c^ + phi*Yt]= c^+phi*c^+ phi^2*Yt
0.2069526*(1-0.4945659) + 0.2069526*(1-0.4945659)*0.4945659 
+ 0.4945659^2*x[108]


#Forecasting h=1;

#Yt+h = mu + phi*et + phi^(2)*et-1 +... + phi^(108)*et-107



for (i in 108:1) {      

  MatrizFIrstForecasting[i]<-residuals[i]*0.4945659^(108-(i-1) )    


#Yt+1 = mu + phi*et + phi^2*et-1 + ... + phi^108*et-107

0.2069526 + sum(Matrizphie) #0.1147776

#Forecasting h=2;

#Yt+h = mu + phi^2*et + phi^(3)*et-1 +... + phi^(109)*et-107
for (i in 108:1) {
MatrizSECONDForecasting[i]<-residuals[i]*0.4945659^(108-(i-2) )

#Yt+2 = mu + phi^2*et + phi^3*et-1 + ... + phi^109*et-107
0.2069526 + sum(MatrizSECONDForecasting) #0.161366

So far so it worked...the problem is that I am not being able toimplement for the third form. I belive my code is wrong.

Could you help me find my mistake?

Third Form: Autoregressive

Y^_t+1|t = pi_1*yt + pi2*yt-1 + ... + pi_108*yt-107... CORRECT?

The PI´s coefficient are obtained like this?

pi_1 = (-phi_1) ; pi_2 = (-phi_1)^2 ; pi_3= (-phi_1)^3; ...;pi_108 = (-phi_1)^108


I build a code for the first forecasting:

for (i in 108:1) {

and the i sum each line of MATRIZpi matrix, to obtain:

Y^_t+1|t = pi_1*yt + pi2*yt-1 + ... + pi_108*yt-107


The value is 0.2099202

Obviously this wrong. I already modified the code a few times and I can not fix.

Could you suggest me something?

  • 1
    $\begingroup$ You state that your model is an AR(1). Therefore it has no MA component. It immediately follows that the first and third form in the linked pdf are equivalent since $\mu(L) = 1$. So if you can do the first form, you can do the third. As near as I can tell, in your description of the third form above, you are confusing the infinite order MA representation of an AR(1) for the actual AR(1). The forecasting equation for an AR(1) is just $\mathbb{E}_t Y_{t+1} = \mu + \phi Y_t$, where $\mu$ is the intercept and $\phi$ is the AR1 coefficient. $\endgroup$ – Colin T Bowers Jul 29 '15 at 23:18
  • $\begingroup$ Thanks! I understand. One more thing...how can i build the code using the prevous Yt values? I need to know how i can achieve the relationship between the PHI´s parameter and the PI´s parameters. As you said the result and idea is the same because $\mu(L) = 1$ is a AR1 process. $\endgroup$ – Linkman Jul 29 '15 at 23:28
  • $\begingroup$ You haven't actually defined $\phi$ or pi in the question, so I can't really answer that question. However, you appear to be using R. So what I can tell you is that the AR1 coefficient estimated by R is the same as the $\phi$ in my previous comment. The intercept estimated by R is not the same as the $\mu$ in my comment. Specifically, R provides estimates in Normal form, which for an AR1 is $(1 - \phi L)(Y_t - c) = \epsilon_t$. So using $\mu$ as defined in my previous comment we have $\mu = c(1 - \phi)$, where $c$ is the intercept estimated output by R. ($L$ is the lag operator) $\endgroup$ – Colin T Bowers Jul 31 '15 at 0:04
  • $\begingroup$ $\phi$ is 0.4945659 .... the coeficient of AR(1) process. I want to know how i can build first forecast point with $\phi$ and Y_t past values... $\endgroup$ – Linkman Jul 31 '15 at 0:07
  • $\begingroup$ Hang on, I'll turn this into an answer. $\endgroup$ – Colin T Bowers Jul 31 '15 at 0:09

I am struggling a little to understand your question, but I suspect I know where you're running into trouble, because it is a question we frequently use on students to test their understanding of how R estimates ARIMA models.

When you estimate an ARIMA model in R, the output is provided in what we often call Normal form. For the specific case of an AR(1) model, the normal form is:

\begin{equation} (1 - \phi L)(Y_t - c) = \epsilon_t \end{equation}

where $L$ is the lag operator, $\phi$ is the AR(1) coefficient, and $c$ is the constant parameter that is output by R. Now, let's say we want to turn all of this into a forecasting equation. We need to get $Y_t$ on the left hand side, and everything else on the right hand side. If you grind through the maths, you'll find that we end up with:

\begin{equation} Y_t = c(1 - \phi) + \phi Y_{t-1} + \epsilon_t \end{equation}

Aha! Note that the intercept term in our forecasting model, ie $c(1 - \phi)$, is not equal to the "intercept" term output by R, which I have denoted just $c$ above. So if you just used $c$ as the intercept term in your forecasting equation, you'll get the wrong answer, which I think is where you're going wrong above.

So, just to be very clear. If $\phi$ is the AR(1) coefficient output by R, and $c$ is the intercept term output by R, then your forecasting equation for an AR(1) should be:

\begin{equation} \mathbb{E}_t Y_{t+1} = c(1 - \phi) + \phi Y_t \end{equation}

where the $\epsilon_{t+1}$ term dropped out because by assumption $\mathbb{E}_t \epsilon_{t+1} = 0$

Note that for an AR(p) model with $p>1$, the correct intercept term to use the forecasting equation is a bit more complicated again. Deriving it is a good exercise. Fortunately, there is no interaction between the $c$ term and any MA coefficients, so for an ARMA(p, q), you only need to worry about the interaction with the AR(p) bit.

If you're struggling with this, the best thing is to write down an ARMA(p,q) in Normal form, and then try and convert it into a forecasting equation, and then try and convert it back. For reference, the Normal form for an ARMA(p,q) is:

\begin{equation} (1 - \phi_1 L - ... - \phi_p L^p) (Y_t - c) = (1 + \theta_1 L + ... + \theta_q L^q) \epsilon_t \end{equation}

  • $\begingroup$ Thanks Colin!. This was one of my problems. What i want is to calculate the first point forecast using the last formula of this first page pdf: link $\endgroup$ – Linkman Jul 31 '15 at 0:27
  • $\begingroup$ The Autoregressive Form. I already did for the first two formulas. I think its confuse. Im sorry. Im gonna try to open another topic (more clearer) these days. $\endgroup$ – Linkman Jul 31 '15 at 0:27
  • $\begingroup$ My problem is this code: MATRIZpi<-matrix(,108,1) for (i in 108:1) { MATRIZpi[i]<-x[108-(108-i)]*(0.4945659)^(108-(i-1)) } . I have to know what is the relationship of $\phi$ = 0.4945659 (on the pdf link is $\alpha$ - Difference Equation Form) and $\pi$ (Autoregressive Form). And then, i fix my code. $\endgroup$ – Linkman Jul 31 '15 at 0:34
  • $\begingroup$ @diogobastos for an ar1, $\alpha(L)$ and $\pi(L)$ are identical, and forecasting equation only includes one lag (as above). Sorry, on phone so not much detail in this comment. $\endgroup$ – Colin T Bowers Jul 31 '15 at 12:58

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.