new; @----------------------------------------------------------@ @::::::: MONMDL.PG4. Estimate the MacDonald-Taylor model @ @ and test rational expectations restrictions @ @ for the deutschemark @ @----------------------------------------------------------@ #include correlgm.set; #include ols.set; #include compan.set; output file=monmdl.ot4 reset; output on; format /rd 8,3; @-----------------------------------------------------------@ t1=100; load cpi[100,19]=cpi.prn; @ CPI data for 19 countries @ load ip[100,19]=ipin.prn; @ Industrial production indices for 19 cos.@ load mon[100,19]=mon.prn; @ Money data for 19 countries @ load spot[100,19]=spot.prn; @ Spot exchange rates for 19 countries @ p=ln(cpi[.,1 2 7 10]); @ US, UK, Germany, Japan @ y=ln(ip[.,1 2 7 10]); m=ln(mon[.,1 2 7 10]); s=ln(spot[.,2])~(-ln(spot[.,7 10])); @ UK, Germany, Japan @ f=(m[.,1]-m[.,2 3 4])-(y[.,1]-y[.,2 3 4]); @ Monetary Fundamentals @ f=f-meanc(f)'; @ Deviations from mean @ z=f-s; z=z-meanc(z)'; @ Deviations from fundamentals--zero mean @ @----------------------------------------------------------@ df=f[2:t1,2]-f[1:t1-1,2]; @ Change in fundmantals--Germany @ z=z[2:t1,2]; @ Germany @ t1=rows(z); @--------------------------------------------------------------@ @--------------------------------------------------------------@ @:::::::::::::::::::::: VAR(k) ::::::::::::::::::::::::::::::::@ @---------Do AIC and BIC to determine lag length---------------@ @--------------------------------------------------------------@ k=4;@ do while k le 20;@ "Lag Length:";; k; j=1; do while j le k; if j eq 1; x1=df[j:t1-k+j-1]; x2=z[j:t1-k+j-1]; endif; if j gt 1; x1=df[j:t1-k+j-1]~x1; x2=z[j:t1-k+j-1]~x2; endif; j=j+1; endo; x=x1~x2; y1=df[k+1:t1]; y2=z[k+1:t1]; {b1,resid1,vcv,tratio1,rsq1}=ols(y1,x,0); "Equation 1: R-square:";; rsq1; " Coeff t-ratio "; b1~tratio1; {b2,resid2,vcv,tratio2,rsq2}=ols(y2,x,0); "Equation 2: R-square:";; rsq2; " Coeff t-ratio "; b2~tratio2; r=resid1~resid2; sigma=r'r/t1; kk=rows(b1)*2; "AIC=";;2*ln(det(sigma))+2*kk/t1; "BIC=";;2*ln(det(sigma))+kk*ln(t1)/t1; @k=k+1; endo;@ @--------------------------------------------------------------@ @-------------- Do the Wald Test ------------------------------@ @--------------------------------------------------------------@ clear R; lam=0.25; psi=lam/(1+lam); Q=x'x/t1; R=eye(2*k)~eye(2*k); v=b1|b2; rr=zeros(k,1)|(1/psi)|zeros(k-1,1); A=sigma.*.inv(Q); B=inv(R*A*R'); C=R*v-rr; TS=t1*C'*B*C; "Lambda : ";;lam; "Wald stat: ";;TS; "P-value : ";;cdfchic(TS,2*k); @--------------------------------------------------------------@ @-------------- Plot actual and Theoretical Spread ------------@ @--------------------------------------------------------------@ alpha=b1'|b2'; B=compan(alpha,2,4); e1=zeros(1,2*k); e1[1,1]=1; zstar=zeros(rows(x),1); @ Theoretical spread @ zact=z[k+1:rows(z)]; @ Actual spread @ t=1; do while t le rows(x); zstar[t]=e1*psi*B*inv(eye(rows(B))-psi*B)*x[t,.]'; t=t+1; endo; @--------------------------------------------------------------@ library pgraph; graphset; fonts("simplex complex microb simgrma"); @ LOAD FONTS @ _pstype = { 8 9 10 11 }; /* controls symbols with graph points */ @ _pline = { 1 6 55 0 1995 0 1 2 1, @ @ 1 6 55 1 1995 1 1 2 1} ; @ _pltype = { 6 }; /* line type for the main curves */ _psymsiz = {5}; @ SYMBOL SIZE @ _plwidth = {9}; @ LINE THICKNESS @ _pdate=""; @----------------------------------------------------------@ caltme=seqa(74,0.25,rows(x)); xtics(74,97,2,1); _plctrl = {0}; _ptitlht = {0.2}; @ TITLE SIZE @ _pstype = {0}; _plegstr = ""; /* title("\202Actual and Theoretical Spread"); */ xy(caltme,zact~zstar); "For Excel Plots"; caltme~zact~zstar; @----------------------------------------------------------@ output off;