* * Enders, Applied Econometric Time Series, 4th edition * Example from Section 6.11, pp 397-400 * Different methods of estimating cointegrating relations * open data quarterly.xls calendar(q) 1960:1 data(format=xls,org=columns) 1960:01 2012:04 * * Results in book use R5, not R10 * linreg r5 # constant tbill set resids = %resids set dresids = resids-resids{1} * @arautolags(crit=bic) resids * * The number of lags on the differences will be one less than the number * on the model as a whole * linreg dresids # resids{1} dresids{1 to 1} * * This can also be done using @EGTestResids * @egtestresids(maxlags=8,method=bic) resids * * Reverse order * linreg tbill # constant r5 * set resids = %resids * @egtestresids(maxlags=8,method=bic) resids * * Johansen test * @varlagselect(lags=8,crit=bic) # r5 tbill * @johmle(lags=2,det=rc,cv=cv,vectors=civectors) # r5 tbill * disp "Cointegrating vectors" civectors disp "Normalized CV" cv/cv(1) * * This imposes the restriction that the cointegrating vector only * involves the "spread" (that is, that the two interest rates are equal * with opposite signs). That's imposed by creating a 2 x 3 matrix D such * that tr(D)*(r5,tbill,1) creates the linear combinations which make up * the cointegrating vector. The first column is (1,-1,0), and the second * is (0,0,1). (If you have CATS, this is all much easier). * * The %%s.. matrices used below are defined by @JOHMLE. * compute [symm] s10_00_01=tr(%%s01)*inv(%%s00)*%%s01 compute d=||1.0,0.0|-1.0,0.0|0.0,1.0|| eigen(general=%mqform(%%s11,d)) %mqform(s10_00_01,d) eigvalr eigvecr * * Create the normalized eigenvector * compute [vector] cvr=%xcol(d*eigvecr,1) compute cvr=cvr/cvr(1) disp "Normalized Restricted CV" cvr * * VECM * equation(coeffs=cvr) ecteq * # r5 tbill constant * * Because the constant is included in the cointegrating vector, it is * *not* included in the VECM. Also, the number of lags is the number of * lags in the expanded system, which is one more than the number of lags * on the differences. * system(model=vecm) variables r5 tbill lags 1 2 ect ecteq end(system) * estimate * * Error correction test (assuming weak exogeneity of the short-term rate) * set dlong = r5-r5{1} set dshort = tbill-tbill{1} * cmom # constant r5{1} tbill{1} dlong{0 to 6} dshort{0 to 6} report(action=define,title="Bivariate Lag Length Selection") report(atrow=1,atcol=1,span) "Bivariate Lag Length Selection" report(atrow=2,atcol=2,tocol=7,span,align=center) "Lags on Change in Long Rate" report(atrow=3,atcol=2,fillby=rows) %seq(1,6) report(atrow=4,atcol=1,fillby=cols) %seq(1,6) do slag=1,6 do llag=1,6 linreg(noprint,cmom) dlong # constant r5{1} tbill{1} dshort dlong{1 to llag} dshort{1 to slag} report(atrow=slag+3,atcol=llag+1) %nobs*log(%sigmasq)+2*%nreg end do llag end do slag report(action=format,atrow=2,atcol=2,width=8,align=decimal,tag=minimum,special=one) report(action=show) * compute llag=6,slag=6 * linreg dlong # constant r5{1} tbill{1} dshort dlong{1 to llag} dshort{1 to slag} * * Test that cointegrating vector has shape proportional to (1,-1). * restrict(create,title="Test that spread is cointegrating relation") 1 # 2 3 # 1 1 0