/* This program is used to graph the ACF and PACF for a AR(2) process. Phi1 is the first-order autoregressive coefficient. Phi2 is the second-order autoregressive coefficient. For the process to be stationary we must have phi1 + phi2 < 1, phi2 - phi1 < 1, and |phi2| < 1. */ data a; array q{30} q1-q30; phi1=0.6; /* You can input the values of two cefficients here*/ phi2=0.2; do lag=1 to 30; if lag=1 then q{lag}=phi1/(1-phi2); else if lag=2 then q{lag}=phi1**2/(1-phi2)+phi2; else q{lag}=phi1*q{lag-1}+phi2*q{lag-2}; rho=q{lag}; if lag=1 then phijj=phi1/(1-phi2); else if lag=2 then phijj=(phi1**2/(1-phi2)+phi2-(phi1/(1-phi2))**2)/(1-(phi1/(1-phi2))**2); else phijj=0; output; end; run; symbol interpol=needle cv=blue ci=black value=dot height=1 width=1; proc gplot data=a; title1 'Theoretical ACF for AR(2) Process'; title2 'with phi1 = 0.6 and phi2 = 0.2'; plot rho*lag; run; title1 'Theoretical PACF for AR(2) Process'; title2 'with phi1 = 0.6 and phi2 = 0.2'; plot phijj*lag; run;