** Use in Chapter 10: Example 10.2 ** all 0 888:1 open data m-ibmspln.dat data(org=obs) / r1 r2 set h1 = 45.0 set h2 = 31.0 set rho = 0.8 nonlin a0 a1 b1 f1 a00 a11 b11 d11 f11 c1 c2 p1 p3 q0 q1 q2 frml a1t = r1(t)-c1-p1*r1(t-1)-p3*r2(t-2) frml a2t = r2(t)-c2 frml gvar1 = a0+a1*a1t(t-1)**2+b1*h1(t-1)+f1*h2(t-1) frml gvar2 = a00+a11*a2t(t-1)**2+b11*h2(t-1)+f11*h1(t-1)+d11*a1t(t-1)**2 frml rh1 = q0 + q1*rho(t-1) + q2*a1t(t-1)*a2t(t-1)/sqrt(h1(t-1)*h2(t-1)) frml rh = exp(rh1(t))/(1+exp(rh1(t))) frml gdet = -0.5*(log(h1(t)=gvar1(t))+log(h2(t)=gvar2(t)) \$ +log(1.0-(rho(t)=rh(t))**2)) frml garchln = gdet-0.5/(1.0-rho(t)**2)*((a1t(t)**2/h1(t))+(a2t(t)**2/h2(t)) \$ -2*rho(t)*a1t(t)*a2t(t)/sqrt(h1(t)*h2(t))) smpl 4 888 compute c1 = 1.4, c2 = 0.7, p1 = 0.1, f1 = -.03, d11=.04, f11=-.06 compute p2 = 0.1, p3 = -0.1, p0 = 0.1, q0 = -2.0, q1 = 3.0, q2 = 0.1 compute a0 = 2.95, a1 = 0.08, b1 = 0.87, a00 = 2.05, a11 = 0.05, b11 = 0.92 *maximize(method=simplex,iterations=10) garchln nlpar(criterion=value,cvcrit=0.00001) maximize(method=bhhh,recursive,iterations=150) garchln set fv1 = gvar1(t) set resi1 = a1t(t)/sqrt(fv1(t)) set residsq = resi1(t)*resi1(t) *** Checking standardized residuals *** cor(qstats,number=20,span=4) resi1 *** Checking squared standardized residuals *** cor(qstats,number=20,span=4) residsq set fv2 = gvar2(t) set resi2 = a2t(t)/sqrt(fv2(t)) set residsq = resi2(t)*resi2(t) *** Checking standardized residuals *** cor(qstats,number=20,span=4) resi2 *** Checking squared standardized residuals *** cor(qstats,number=20,span=4) residsq *** Last few observations needed for forecasts *** set rhohat = rho(t) set shock1 = a1t(t) set shock2 = a2t(t) print 885 888 shock1 shock2 fv1 fv2 rhohat