# Computing correlation coefficient for an AR(2) process in R using Yule-Walker equation for rho (for several lags) [closed]

I have a time series problem where I could easily work out the solution manually. The only problem is that it would take a long time since I have 4 different AR(2) processes and want to calculate at least the first 20 lagged correlations for each.. I still have R on my PC from previous work which was much easier though and I feel like I forgot everything I knew about it, So I'm sitting in front of it not knowing how to work this out. What I want to do is use the Yule-Walker equation for rho as follows:

I got an (actually four, but lets just do one for the sake of it) autoregressive process of second order, AR(2) Phi(1) is 0.6 and Phi(2) is 0.4.

I want to calculate the correlation coefficients rho(k) for all lags up to k=20.

So rho(0) would naturally be 1 and rho(-1) = rho(1) therefore

rho(1) = phi(1) + phi(2)*rho(1)
rho(k) = phi(1)*rho(k-1) + phi(2)*rho(k-2)


Now I want to solve this in R. But I have no idea how to do it. Can anyone help me out here?

I'd be very grateful!

Thanks. Max

-
 I thought the idea of solving the Yule_Walker equations for the correlations might be on topic and interesting. The solution is easy algebra given the estimated AR coefficients and in computing the correlations for the given example the roots of the characteristic polynomial indicate nonstationarity. – Michael Chernick Sep 27 '12 at 4:21

## closed as off topic by whuber♦Sep 27 '12 at 4:10

Questions on Cross Validated are expected to relate to statistics within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.