options crt; name armaxc "ARMA(12,2) Example" ; ? ? ARMA(12,2) estimation, using a method from ? Andrew Harvey, The Econometric Analysis of Time Series (1990) p.273 ? ? TSP 4.3 (September 1995) ? Author: Clint Cummins ? ?fetch e1; ? (Pindyck & Rubinfeld data) load ; ? list bnames phi1-phi12 theta1-theta2 alpha; param bnames; ? zero starting values -- converges in 45 iterations mmake b bnames; ? to SSR = 135.27569 ? ? Try starting values from MicroTSP handbook, to verify their SSR ? of 136.6999 (this checks). After another 31 iterations, the ? solution above is reached (with a better SSR). ? mmake b 1.1087608 -.3156806 .1159227 -.1885951 .4076379 -.3692521 .1075082 .0634516 .1786308 -.2201502 .0850142 -.0038033 -.0007017 .0024705 -.3528025 ; unmake b bnames; ? frml equ u = e1 - alpha; genr equ; copy @smpl usmpl; ? ? Equation for residual ? frml eqe e = u - phi1*u(-1) - phi2*u(-2) - phi3*u(-3) - phi4*u(-4) - phi5*u(-5) - phi6*u(-6) - phi7*u(-7) - phi8*u(-8) - phi9*u(-9) - phi10*u(-10) - phi11*u(-11) - phi12*u(-12) - theta1*e(-1) - theta2*e(-2); ? Equations for derivatives of residual with respect to parameters frml d1 dedp1 = -u(-1) - theta1*dedp1(-1) - theta2*dedp1(-2); frml d2 dedp2 = -u(-2) - theta1*dedp2(-1) - theta2*dedp2(-2); frml d3 dedp3 = -u(-3) - theta1*dedp3(-1) - theta2*dedp3(-2); frml d4 dedp4 = -u(-4) - theta1*dedp4(-1) - theta2*dedp4(-2); frml d5 dedp5 = -u(-5) - theta1*dedp5(-1) - theta2*dedp5(-2); frml d6 dedp6 = -u(-6) - theta1*dedp6(-1) - theta2*dedp6(-2); frml d7 dedp7 = -u(-7) - theta1*dedp7(-1) - theta2*dedp7(-2); frml d8 dedp8 = -u(-8) - theta1*dedp8(-1) - theta2*dedp8(-2); frml d9 dedp9 = -u(-9) - theta1*dedp9(-1) - theta2*dedp9(-2); frml d10 dedp10 = -u(-10) - theta1*dedp10(-1) - theta2*dedp10(-2); frml d11 dedp11 = -u(-11) - theta1*dedp11(-1) - theta2*dedp11(-2); frml d12 dedp12 = -u(-12) - theta1*dedp12(-1) - theta2*dedp12(-2); frml d13 dedt1 = -e(-1) - theta1*dedt1(-1) - theta2*dedt1(-2); frml d14 dedt2 = -e(-2) - theta1*dedt2(-1) - theta2*dedt2(-2); frml d15 deda = -1+phi1+phi2+phi3+phi4+phi5+phi6 +phi7+phi8+phi9+phi10+phi11+phi12 - theta1*deda(-1) - theta2*deda(-2); list deqs d1-d15; list dvars dedp1-dedp12 dedt1-dedt2 deda; ? ? zero the presample values ? smpl 60:11 88:6; dot e dvars; . = 0; enddot; ? smpl 61:1 88:6; ? u exists from 60:1 ; use 12 lags genr eqe; copy @smpl esmpl; mat ssrold = e'e; print ssrold; ? mat novar = nrow(b); supres @logl @nob @coef @smpl; const maxit,50 maxsqz,10 tol,.001; do iter=1,maxit; dot deqs; genr(silent) .; enddot; ? Gauss-Newton iteration: regress e on derivatives ols(silent) e dvars; rename @coef delt; ? test for convergence and squeeze to find stepsize. mat worst = max(abs(delt)/(abs(b) + 10*tol)); if worst