Wednesday, September 2, 2015

Stationarity Condition of AR Process

To replicate, You can download the data (here). In this blog, I will discuss about the stationarity process of an $AR(p)$ process for ${{y}_{t}}$.

Let’s define an$AR(p)$ process for ${{y}_{t}}$ which is given as:
$yt={{\phi }_{1}}{{y}_{t-1}}+{{\phi }_{2}}{{y}_{t-2}}+\cdots +{{\phi }_{p}}{{y}_{t-p}}+\mu +{{v}_{t}}$

This equation can be expressed as:
${{y}_{t}}-{{\phi }_{1}}{{y}_{t-1}}-{{\phi }_{2}}{{y}_{t-2}}-\cdots -{{\phi }_{p}}{{y}_{t-p}}=\mu +{{v}_{t}}$

Now, let’s use a backshift or lag operator i.e. $(B{{y}_{t}}={{y}_{t-1}},{{B}^{2}}{{y}_{t}}={{y}_{t-2}},\cdots {{B}^{p}}{{y}_{t}}={{y}_{t-p}})$.

Then the above expression can be written as:
${{y}_{t}}-{{\phi }_{1}}B{{y}_{t}}-{{\phi }_{2}}{{B}^{2}}{{y}_{t}}-\cdots -{{\phi }_{p}}{{B}^{p}}{{y}_{t}}=\mu +{{v}_{t}}$

Now, we can take ${{y}_{t}}$ common,
$(1-{{\phi }_{1}}B-{{\phi }_{2}}{{B}^{2}}-\cdots -{{\phi }_{p}}{{B}^{p}}){{y}_{t}}=\mu +{{v}_{t}}$

Now, we can write
${{\phi }_{p}}(B){{y}_{t}}=\mu +{{v}_{t}}$

${{\phi }_{p}}(B)=1-{{\phi }_{1}}B-{{\phi }_{2}}{{B}^{2}}-\cdots -{{\phi }_{p}}{{B}^{p}}$

For the stationarity condition,
The ${yt}$ is stationary when the roots of the characteristic polynomial lie outside the unit circle. The modulus of polynomials roots of ${{\phi }_{p}}(B)$ i.e $|{{z}_{i}}|>1$ or $|{{\phi }_{i}}|>1$.

Let’s discuss the stationary condition of an $AR(p)$ process for ${{y}_{t}}$with a practical example. You can download the data (here). At first let’s load the monthly data of US interest rate from January 1960 till December 1998 and save that to object called “r”.  Now, Let’s develop an $AR(4)$ process for “r” and save it to a new object called “ar_r”.

rm (list = ls(all=TRUE))
data = read.table("C:/.../rate.csv", header=T, quote="\"")
lag_r <- 4
ar_r  <- arima(r,order=c(lag_r,0,0))

This will generate the following output:

Hence, our equation can be given as:
  & {{r}_{t}}=1.417{{r}_{t-1}}-0.587{{r}_{t-2}}+0.125{{r}_{t-3}}+0.024{{y}_{t-4}}+6.161+{{v}_{t}} \\
 & or,{{r}_{t}}-1.417{{r}_{t-1}}+0.587{{r}_{t-2}}-0.125{{r}_{t-3}}-0.024{{y}_{t-4}}=6.161+{{v}_{t}} \\

Now, when we use Lag operator,

Now we can solve for values of $z$ in the equation$(1-1.417z+0.587{{z}^{2}}-0.125{{z}^{3}}-0.024{{z}^{4}})$.

To do such in R, let’s extract the coefficients from the object “ar_r” and save that to object called “phi”.

phi <- ar_r$coef

Then concatenate the 1 and the coefficients which their sigh reversed and save that to object called “c”.
c  <- c(1, -phi[1:lag_r])

Finally, we can find the polynomials or the roots using following command. Let’s save such polynominals in object called “rt”
rt <- polyroot( c )

See the following diagram.

Here, two real roots and tow complex roots $(1-1.417z+0.587{{z}^{2}}-0.125{{z}^{3}}-0.024{{z}^{4}})$ are given as

  & {{z}_{1}}=1.028; \\
 & {{z}_{2}}={{z}_{3}}=1.285+1.716i; \\
 & {{z}_{4}}=-8.753 \\

Let’s represent these in modulus term using “complex” command and “modulus=Mod(rt)” and save it in “zz.shift” object. The modulus of complex number ${{z}_{3}}=1.285+1.716i$ is given as: $\sqrt{{{(1.285)}^{2}}+{{(1.716)}^{2}}}=2.141$ .

zz.shift <- complex(modulus = Mod(rt))

The moduli of roots are given as:
  & |{{z}_{1}}|=1.028; \\
 & |{{z}_{2}}|=|{{z}_{3}}|=2.141; \\
 & |{{z}_{4}}|=8.753 \\

The modulus of polynomials roots of ${{\phi }_{p}}(B)$ i.e $|{{z}_{i}}|>1$ or outside of unit root circle, hence this $AR(4)$ process for “r” is stationary. A plot can be developed with following codes.

# Plotting the roots in a unit circle
x <- seq(-1, 1, length = 1000)
y1 <- sqrt(1- x^2)
y2 <- -sqrt(1- x^2)
plot(c(x, x), c(y1, y2), xlab='Real part',
     ylab='Complex part', type='l',
     main='Unit Circle', ylim=c(-2, 2), xlim=c(-2, 2))
       Im(polyroot(c)), pch=19)
legend(-1.5, -1.5, legend="Roots of AR(2)", pch=19)

Pfaff, Bernhard (2008), Analysis of Integrated and Cointegrated Time Series with R, Springer Publishing Company
Martin, Vance, Hurn, Stan, & Harris, David (2013) Econometric Modelling with Time Series : Specification, Estimation and Testing. Themes in Modern Econometrics. Cambridge University Press, New York.