/* -------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------- */ This program file contains programs and libraries for "Testing the Expectations Hypothesis: Some New Evidence for Japan" by Daniel L. Thornton in the September/October 2004 issue of the Federal Reserve Bank of St. Louis Review. This file consists of 2 GAUSS programs (Tables 4 and 5), 1 EViews program (Figures 2 and 6), and 2 GAUSS library files. The library used by the individual program is noted in comments at the beginning of each program. The Gauss programs use the file 0409dtd.txt. To create this file, export the LEVELS group from the EViews workfile (without the date column). 0409dtd.txt are end of month observations for the period March 1981 to January 2003. The rates include the three-month gensaki rate and rates on Japanese government bonds (JGBs) with maturities of 0-1 year, 1-2 years, -3 years, up to 9-10 years. The gensaki rate was obtained from the Japan Securities Dealers Association. **MORE INFORMATION ON CREATING FIGURES AND TABLES USING 0409DTD.WF1 and 0409DTP.TXT***; /***FIGURES****/ Figure 1: This is constructed using the two level series, R3 and R114, from the eviews file, 0409dtd.wf1. Figure 2: This chart is created using the eviews program file, rolling.prg (saved in this file), with the eviews file, 0409dtd.wf1. After running the eviews program, the data from columns 1,7,and 11 of _dfstat (a eviews matrix from the program output) are used to construct the chart for figure 2. column 1=r3 column 7=r66 column 11=r114 Figure 3: The data used to construct the raios are series r3-r114 in the eviews file, 0409dtd.wf1. Figure 4: The data used to construct the raios are series dr3-dr114 in the eviews file, 0409dtd.wf1. Figure 5: This is constructed using the two series, d6 and d114 (d6 and d114 are the simple differences between r* and r3), from the eviews file, 0409dtd.wf1. Figure 6: This chart is created using the eview program file, rolling.prg (saved in this file), with the eviews file, 0409dtd.wf1. After running the eviews program, the data from columns 12,16,and 21 of _dfstat (a eviews matrix) are used to construct the chart for figure 2. column 12=r6-r3 column 16=r54-r3 column 21=r114-r3 /***TABLES****/ Table 1: This table contains Augmented Dickey-Fuller Tests for Japanese Treasury Rates. To obtain the results, just simply run the augmented DF test for series R3-R114 in the eviews file, 0409dtd.wf1. Table 2: This table contains Augmented Dickey-Fuller Tests for Japanese Treasury Rate Spreads. To obtain the results, just simply run the augmented DF test for series d6-d114 in the eviews file, 0409dtd.wf1. Table 3: The results for this table are obtained from running the Cointergration test in eviews. The names for the data series in the eviews file are labeled the same way as the column titles in table 3. Table 4: Program file-Ehfit_level.gss; Library file-Gaert.lib; Data file-level.txt The program and the library files are stored in this file. Table 5: Program file-Ehfit_diff.gss; Library file-Gaert_diff.lib; Data file-level.txt The program and the library files are stored in this file /* -------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------- */ @The following programs produces Table 4 and 5 in the review article@ /*****************Ehfit_level.gss**********************************************************/ /*This program produces the LM Statistics for LM Testing Using Level Data In order to get the right results, two following parameters needs to be modified before every run. 1) __lagno : This parameter takes values, 1,2,3. The number indicates the lagno used in the main program. The lag number is right next to the significance level in every cell of the table. 2) __datespan: This parameter takes values: 1,2,3. 1=Mar. 1981 to Jan. 2003 2=Mar. 1981 to Oct. 1990 3=Nov.1990 to June 1998 This program also needs the library file, Gaert.lib, and the data file, 0409dtd.txt. */ /********parameters******************/ __lagno = 1; __datespan = 2; /************************************/ #INCLUDE h:\thornton\gensaki\gaert.lib; cls; @ Load Campbell-Shiller data @ LOAD shilRate[] = h:\thornton\gensaki\0409dtd.txt; shilRate = RESHAPE(shilRate,ROWS(shilRate)/11,11); @ First row is maturity @ perNum = shilRate[1,.]'; shilRate = shilRate[2:ROWS(shilRate),.]; @cut n observations for shorter dates oct 1990=147 june 1998=55 90.11-98.06 116,44@ if __datespan .eq 1; i=0; n=147; elseif __datespan .eq 2; i=0; n=55; elseif __datespan .eq 3; i=116; n=44; endif; shilrate=shilrate[1+i:rows(shilrate)-n,.]; @mean adjust@ shilrate=shilrate-meanc(shilrate)'; @ Loop over estimates for 1 and 2 lags @ lagNo = __lagno; DO WHILE lagNo <= __lagno; @ Output file for results @ OUTPUT FILE = h:\thornton\gensaki\jend.out ON; OUTPUT ON; @ Dimensions of VAR coefficient matrix @ _rows = 2*lagNo; _cols = 2; @ Matrices of results @ chiMat = MISS(ZEROS(ROWS(perNum),ROWS(perNum)),0); pMat = chiMat; @ Estimate constrained VAR's and calculate test statistic for conformable interest rate data @ i = 1; DO WHILE i <= ROWS(perNum); j = i + 1; DO WHILE j <= ROWS(perNum); @ Maturities of short and long rate @ _m= perNum[i]; _n = perNum[j]; _k = _n/_m; IF _k == ROUND(_k); @ Rates are conformable @ @ Estimate unrestricted VAR and calculate residuals @ y = shilRate[.,i j]; {yMat,xMat,piMatUR} = NoMeanVAR(y,SEQA(1,1,lagNo)); resids = yMat - (piMatUR'*xMat')'; @ Estimate of var.-cov. matrix of moment conditions @ omegT = calcgt(yMat,xMat,piMatUR); omegT = (omegT'*omegT)/ROWS(omegT); @ Matrices fixed during parameter estimation @ capY = (xMat'*yMat)/ROWS(xMat); capX = (xMat'*xMat)/ROWS(xMat); capGT = -(EYE(_cols).*.capX); @ termCond is maximum of a(theta) - the vector of equality constraints @ piMatR = piMatUR; aT = EHconst(VEC(piMatR)); termcond = MAXC(ABS(aT)); @ Number of iterations @ itNum = 1; DO WHILE termCond >= 1e-8 AND itNum <= 100; capBT = capGT'*(capGT/omegT); invBT = INV(capBT); @ Vector of moment conditions @ geet = VEC(capY) + capGT*VEC(piMatR); @ Derivative of equality constraints @ capAT = GRADP(&EHconst,VEC(piMatR)); IF MAXC(ABS(VEC(capAT))) >= 1e+100; itNum = 200; ELSE; @ Var.-Cov. matrix of multipliers @ multVCV = INV(capAT*(capAT'/capBT)); @ Var.-Cov. matrix of parameters @ paramVCV = invBT - invBT*capAT'*multVCV*capAT*invBT; @ Update estimate of constrained VAR matrix @ piVEC = VEC(piMatR) - paramVCV*capGT'*(geeT/omegT) - invBT*capAT'*multVCV*aT; piMatR = RESHAPE(piVEC,_cols,_rows)'; @ Update vector of equality constraints and termCond @ aT = EHconst(VEC(piMatR)); termCond = MAXC(ABS(aT)); itNum = itNum + 1; ENDIF; ENDO; @ Output results @ "Short rate -" _m "months"; "Long rate -" _n "months"; "Unrestricted coefficient matrix for" lagNo "lags"; piMatUR; @ Maximum eigenvalue of un-restricted VAR @ {theta,errs} = makeFOVAR(piMatUR,0); eigs = -SORTC(-ABS(EIG(theta)),1); IF eigs[1] > 1; ""; "Unrestricted VAR is unstable"; ELSE; ""; "Maximum Eigenvalue of unrestricted VAR -" eigs[2]; ENDIF; IF termCond > 1e-8; ""; "B-H method failed to converge"; ""; "-------------------------------------------------------------"; ""; ELSE; ""; "Restricted coefficient matrix"; piMatR; @ Stable or unstable constrained VAR? @ {theta,dumm} = makeFOVAR(piMatR,0); maxEig = MAXC(ABS(EIG(theta))); IF maxEig > 1; ""; "Constrained VAR is unstable"; "Max. Eigenvalue -" maxEig; ELSE; ""; "Constrained VAR is stable"; ENDIF; @ Chi-square statistic @ chi2Stat = ROWS(yMat)*geeT'*(geeT/omegT); chiMat[j,i] = chi2Stat; pValue = CDFCHIC(chi2Stat,ROWS(aT)); pMat[j,i] = pValue; "Lagrange multiplier statistic -" chi2Stat; "p-Value of LM stat. -" pValue; ""; "-------------------------------------------------------------"; ""; ENDIF; ENDIF; j = j + 1; ENDO; i = i + 1; ENDO; @ Output statistics @ OUTPUT OFF; OUTWIDTH 256; OUTPUT FILE = stats.out ON; perNum'; i = 1; DO WHILE i <= ROWS(perNum); chiMat[i,.]; pMat[i,.]; i = i + 1; ENDO; OUTPUT OFF; lagNo = lagNo + 1; ENDO; /*****************Ehfit_diff.gss**********************************************************/ /*This program produces the LM Statistics for LM Testing. In order to get the right results, two following parameters needs to be modified before every run. 1) __lagno : This parameter takes values, 1,2,3. The number indicates the lagno used in the main program. The lag number is right next to the significance level in every cell of the table. 2) __datespan: This parameter takes values: 1,2,3. 1=Mar. 1981 to Jan. 2003 2=Mar. 1981 to Oct. 1990 3=Nov.1990 to June 1998 This program also needs the library file, Gaert_diff.lib, and the data file, 0409dtd.txt. */ /********parameters******************/ __lagno = 1; __datespan = 1; /************************************/ #INCLUDE h:\thornton\gensaki\gaert_diff.lib; cls; @ Load Campbell-Shiller data @ LOAD shilRate[] = h:\thornton\gensaki\0409dtd.txt; shilRate = RESHAPE(shilRate,ROWS(shilRate)/11,11); @ First row is maturity @ perNum = shilRate[1,.]'; shilRate = shilRate[2:ROWS(shilRate),.]; @cut n observations for shorter dates oct 1990=147 june 1998=55 90.11-98.06 116,44 90.11-98.06: rows(shilrate)-146 to n=44@ if __datespan .eq 1; i=0; n=147; elseif __datespan .eq 2; i=0; n=55; elseif __datespan .eq 3; i=116; n=44; endif; shilrate=shilrate[1+i:rows(shilrate)-n,.]; /***different from levels version****/ diff=shilrate[2:rows(shilrate),.]-shilrate[1:rows(shilrate)-1,.]; @ Loop over estimates for 1 and 2 lags @ lagNo = __lagno; DO WHILE lagNo <= __lagno; @ Output file for results @ OUTPUT FILE = h:\thornton\gensaki\jend.out ON; OUTPUT ON; @ Dimensions of VAR coefficient matrix @ _rows = 2*lagNo; _cols = 2; @ Matrices of results @ chiMat = MISS(ZEROS(ROWS(perNum),ROWS(perNum)),0); pMat = chiMat; @ Estimate constrained VAR's and calculate test statistic for conformable interest rate data @ i = 1; DO WHILE i <= ROWS(perNum); j = i + 1; DO WHILE j <= ROWS(perNum); @ Maturities of short and long rate @ _m= perNum[i]; _n = perNum[j]; _k = _n/_m; IF _k == ROUND(_k); @ Rates are conformable @ @ Estimate unrestricted VAR and calculate residuals @ /***different from levels version***/ y=diff[.,i]~(shilrate[2:rows(shilrate),j]-shilrate[2:rows(shilrate),i]); {yMat,xMat,piMatUR} = NoMeanVAR(y,SEQA(1,1,lagNo)); resids = yMat - (piMatUR'*xMat')'; @ Estimate of var.-cov. matrix of moment conditions @ omegT = calcgt(yMat,xMat,piMatUR); omegT = (omegT'*omegT)/ROWS(omegT); @ Matrices fixed during parameter estimation @ capY = (xMat'*yMat)/ROWS(xMat); capX = (xMat'*xMat)/ROWS(xMat); capGT = -(EYE(_cols).*.capX); @ termCond is maximum of a(theta) - the vector of equality constraints @ piMatR = piMatUR; aT = EHconst(VEC(piMatR)); termcond = MAXC(ABS(aT)); @ Number of iterations @ itNum = 1; DO WHILE termCond >= 1e-8 AND itNum <= 100; capBT = capGT'*(capGT/omegT); invBT = INV(capBT); @ Vector of moment conditions @ geet = VEC(capY) + capGT*VEC(piMatR); @ Derivative of equality constraints @ capAT = GRADP(&EHconst,VEC(piMatR)); IF MAXC(ABS(VEC(capAT))) >= 1e+100; itNum = 200; ELSE; @ Var.-Cov. matrix of multipliers @ multVCV = INV(capAT*(capAT'/capBT)); @ Var.-Cov. matrix of parameters @ paramVCV = invBT - invBT*capAT'*multVCV*capAT*invBT; @ Update estimate of constrained VAR matrix @ piVEC = VEC(piMatR) - paramVCV*capGT'*(geeT/omegT) - invBT*capAT'*multVCV*aT; piMatR = RESHAPE(piVEC,_cols,_rows)'; @ Update vector of equality constraints and termCond @ aT = EHconst(VEC(piMatR)); termCond = MAXC(ABS(aT)); itNum = itNum + 1; ENDIF; ENDO; @ Output results @ "Short rate -" _m "months"; "Long rate -" _n "months"; "Unrestricted coefficient matrix for" lagNo "lags"; piMatUR; @ Maximum eigenvalue of un-restricted VAR @ {theta,errs} = makeFOVAR(piMatUR,0); eigs = -SORTC(-ABS(EIG(theta)),1); IF eigs[1] > 1; ""; "Unrestricted VAR is unstable"; ELSE; ""; "Maximum Eigenvalue of unrestricted VAR -" eigs[2]; ENDIF; IF termCond > 1e-8; ""; "B-H method failed to converge"; ""; "-------------------------------------------------------------"; ""; ELSE; ""; "Restricted coefficient matrix"; piMatR; @ Stable or unstable constrained VAR? @ {theta,dumm} = makeFOVAR(piMatR,0); maxEig = MAXC(ABS(EIG(theta))); IF maxEig > 1; ""; "Constrained VAR is unstable"; "Max. Eigenvalue -" maxEig; ELSE; ""; "Constrained VAR is stable"; ENDIF; @ Chi-square statistic @ chi2Stat = ROWS(yMat)*geeT'*(geeT/omegT); chiMat[j,i] = chi2Stat; pValue = CDFCHIC(chi2Stat,ROWS(aT)); pMat[j,i] = pValue; "Lagrange multiplier statistic -" chi2Stat; "p-Value of LM stat. -" pValue; ""; "-------------------------------------------------------------"; ""; ENDIF; ENDIF; j = j + 1; ENDO; i = i + 1; ENDO; @ Output statistics @ OUTPUT OFF; OUTWIDTH 256; OUTPUT FILE = stats.out ON; perNum'; i = 1; DO WHILE i <= ROWS(perNum); chiMat[i,.]; pMat[i,.]; i = i + 1; ENDO; OUTPUT OFF; lagNo = lagNo + 1; ENDO; /*****************Gaert.lib**********************************************************/ /*This is the library file for Ehfit_level.gss*/ CLEAR _rows,_cols,_n,_m,_k; /* Procedure to calculate restrictions on VAR parameters. It takes as an argument, VEC(pimat), wher pimat is the coefficient matrix in the VAR y[t] = pimat'*x[t] where x[t] = y[t-1]|y[t-2]|...|y[t-r] */ PROC (1) = EHconst(params); LOCAL piMat,theta,errs,lam,P,aTheta,h; piMat = RESHAPE(params,_cols,_rows)'; {theta,errs} = makeFOVAR(piMat,0); {lam,P} = EIGV(theta); aTheta = EYE(_rows)/_k; h = 1; DO WHILE h <= (_k-1); aTheta = aTheta + REAL(P*DIAGRV(EYE(_rows),lam^(_m*h))*INV(P))/_k; h = h + 1; ENDO; aTheta = -aTheta[1,.]'; aTheta[2] = 1 + aTheta[2]; RETP(aTheta); ENDP; /* Procedure to calculate a matrix of moment conditions from the data, yMat and xMat, and the current coefficient matrix. By definition, the ith row of the matrix returned is the Kronecker product of the VAR residual at time i, and the VAR lags at time i. */ PROC (1) = calcgt(yMat,xMat,piMat); LOCAL obsNum,i,gtMat,geet; obsNum = ROWS(yMat); i = 1; gtMat = ZEROS(obsNum,COLS(yMat)*COLS(xMat)); DO WHILE i <= obsNum; geet = (yMat[i,.]' - piMat'*xMat[i,.]').*.xMat[i,.]'; gtMat[i,.] = VEC(geet)'; i = i + 1; ENDO; RETP(gtMat); ENDP; /* Procedure to generate two data matrices convenient for use in fitting a VAR. The arguments are a T by n matrix of data for use in the VAR, and a vector, lagStruc, specifying the lags of this data to be used in the fit. The procedure returns two matrices. The second is the matrix xMat = (ONES~LAGN(yData,lagStruc)) and the first is yMat, which is yData with the first few observations discarded to make up for the missing values in lags of yData. */ PROC (2) = VARMats(yData,lagStruc); LOCAL lagNo,yDim,capT,XMat,i,YMat; IF lagStruc /= 0; lagNo = ROWS(lagStruc); ELSE; lagNo = 0; ENDIF; yDim = COLS(yData); capT = ROWS(yData); XMat = ONES(capT,1); IF lagNo > 0; i = 1; DO WHILE i <= lagNo; XMat = XMat~LAGN(yData,lagStruc[i]); i = i + 1; ENDO; ENDIF; XMat = PACKR(yData~XMat); YMat = XMat[.,1:yDim]; XMat = XMat[.,(yDim+1):COLS(XMat)]; RETP(YMat,XMat); ENDP; /* Procedure to demean a data set so that a VAR fitted to the demeaned data will have a zero constant term. The arguments are a T by n matrix of data for use in the VAR, and a vector, lagStruc, specifying the lags of this data to be used in the fit. The procedure returns two matrices and a matrix of VAR coefficients. The second matrix is xMat = LAGN(yData,lagStruc) - mu' and the first is yMat = yData - mu, which is the demeaned yData with the first few observations discarded to make up for the missing values in lags of yData. Both of these data matrices have been demeaned so that a VAR regression of yMat on xMat and a constant will result in a zero value of that constant. The matrix piMat is a matrix of VAR coefficients in the regression: (y[t] - mu) = piMat'(x[t] - mu) */ PROC (3) = NoMeanVAR(yData,lagStruc); LOCAL YMat,XMat,piMat,kapp,yDim,lagNo,mu; @ Matrices of dependent and independent regressors including constant @ {YMat,XMat} = VARMats(yData,lagStruc); @ Regression coefficients including constant @ piMat = (xMat'yMat)/(xMat'xMat); kapp = piMat[1,.]'; @ Dimension of VAR and number of lags @ yDim = COLS(YMat); lagNo = (ROWS(piMat) - 1)/yDim; @ Unconditional mean of estimated VAR @ mu = EYE(yDim) - piMat'*(ZEROS(1,yDim)|(ONES(lagNo,1).*.EYE(yDim))); mu = kapp/mu; @ Return demeaned data matrices and coefficient matrix @ YMat = YMat - mu'; XMat = XMat[.,2:COLS(XMat)]; XMat = XMat - (ONES(lagNo,1).*.mu)'; piMat = piMat[2:ROWS(piMat),.]; RETP(YMat,XMat,piMat); ENDP; /* Procedure to turn the coefficient matrix of a VAR of the form y[t] = piMat'*x[t], where x[t] = y[t-1]|y[t-2]|...|y[t-r], into a coefficient matrix of a corresponding first order VAR. In addition the procedure will take a matrix of estimated VAR errors and return a matrix of corresponding errors for the first order VAR. */ PROC (2) = makeFOVAR(pimat,resids); LOCAL T,lagNo,varNo,rowNo,theta,errs; T = ROWS(resids); varNo = COLS(piMat); rowNo = ROWS(piMat); lagNo = rowNo/varNo; IF lagNo >= 2; theta = piMat'|(EYE(rowNo-varNo)~ZEROS(rowNo-varNo,varNo)); errs = resids~ZEROS(T,rowNo-varNo); ELSE; theta = piMat'; errs = resids; ENDIF; RETP(theta,errs); ENDP; /*****************Gaert_diff.lib**********************************************************/ /*This is the library file for Ehfit_diff.gss*/ CLEAR _rows,_cols,_n,_m,_k; /* Procedure to calculate restrictions on VAR parameters. It takes as an argument, VEC(pimat), wher pimat is the coefficient matrix in the VAR y[t] = pimat'*x[t] where x[t] = y[t-1]|y[t-2]|...|y[t-r] */ PROC (1) = EHconst(params); LOCAL piMat,theta,errs,lam,P,aTheta,h,theta_m,theta_n; piMat = RESHAPE(params,_cols,_rows)'; {theta,errs} = makeFOVAR(piMat,0); /*{lam,P} = EIGV(theta); lam;p;pimat;end; aTheta = EYE(_rows)/_k; h = 2; DO WHILE h <= (_k-1); aTheta = aTheta + REAL(P*DIAGRV(EYE(_rows),lam^(_m*h))*INV(P))/_k; h = h + 1; ENDO; aTheta = -aTheta[1,.]';*/ @A=theta@ @EYE(_rows)@ theta_n=EYE(_rows); h=2; do while h<=_n; theta_n=theta_n*theta; h=h+1; endo; theta_n=(eye(_rows)-theta_n); theta_m=EYE(_rows); h=1; do while h<=_m; theta_m=theta_m*theta; h=h+1; endo; theta_m=(eye(_rows)-theta_m); theta_m=inv(theta_m); atheta=theta*(eye(_rows)-(_m/_n)*theta_n*theta_m)*inv(eye(_rows)-theta); atheta=-atheta[1,.]'; aTheta[2] = 1 + aTheta[2]; RETP(aTheta); ENDP; /* Procedure to calculate a matrix of moment conditions from the data, yMat and xMat, and the current coefficient matrix. By definition, the ith row of the matrix returned is the Kronecker product of the VAR residual at time i, and the VAR lags at time i. */ PROC (1) = calcgt(yMat,xMat,piMat); LOCAL obsNum,i,gtMat,geet; obsNum = ROWS(yMat); i = 1; gtMat = ZEROS(obsNum,COLS(yMat)*COLS(xMat)); DO WHILE i <= obsNum; geet = (yMat[i,.]' - piMat'*xMat[i,.]').*.xMat[i,.]'; gtMat[i,.] = VEC(geet)'; i = i + 1; ENDO; RETP(gtMat); ENDP; /* Procedure to generate two data matrices convenient for use in fitting a VAR. The arguments are a T by n matrix of data for use in the VAR, and a vector, lagStruc, specifying the lags of this data to be used in the fit. The procedure returns two matrices. The second is the matrix xMat = (ONES~LAGN(yData,lagStruc)) and the first is yMat, which is yData with the first few observations discarded to make up for the missing values in lags of yData. */ PROC (2) = VARMats(yData,lagStruc); LOCAL lagNo,yDim,capT,XMat,i,YMat; IF lagStruc /= 0; lagNo = ROWS(lagStruc); ELSE; lagNo = 0; ENDIF; yDim = COLS(yData); capT = ROWS(yData); XMat = ONES(capT,1); IF lagNo > 0; i = 1; DO WHILE i <= lagNo; XMat = XMat~LAGN(yData,lagStruc[i]); i = i + 1; ENDO; ENDIF; XMat = PACKR(yData~XMat); YMat = XMat[.,1:yDim]; XMat = XMat[.,(yDim+1):COLS(XMat)]; RETP(YMat,XMat); ENDP; /* Procedure to demean a data set so that a VAR fitted to the demeaned data will have a zero constant term. The arguments are a T by n matrix of data for use in the VAR, and a vector, lagStruc, specifying the lags of this data to be used in the fit. The procedure returns two matrices and a matrix of VAR coefficients. The second matrix is xMat = LAGN(yData,lagStruc) - mu' and the first is yMat = yData - mu, which is the demeaned yData with the first few observations discarded to make up for the missing values in lags of yData. Both of these data matrices have been demeaned so that a VAR regression of yMat on xMat and a constant will result in a zero value of that constant. The matrix piMat is a matrix of VAR coefficients in the regression: (y[t] - mu) = piMat'(x[t] - mu) */ PROC (3) = NoMeanVAR(yData,lagStruc); LOCAL YMat,XMat,piMat,kapp,yDim,lagNo,mu; @ Matrices of dependent and independent regressors including constant @ {YMat,XMat} = VARMats(yData,lagStruc); @ Regression coefficients including constant @ piMat = (xMat'yMat)/(xMat'xMat); kapp = piMat[1,.]'; @ Dimension of VAR and number of lags @ yDim = COLS(YMat); lagNo = (ROWS(piMat) - 1)/yDim; @ Unconditional mean of estimated VAR @ mu = EYE(yDim) - piMat'*(ZEROS(1,yDim)|(ONES(lagNo,1).*.EYE(yDim))); mu = kapp/mu; @ Return demeaned data matrices and coefficient matrix @ YMat = YMat - mu'; XMat = XMat[.,2:COLS(XMat)]; XMat = XMat - (ONES(lagNo,1).*.mu)'; piMat = piMat[2:ROWS(piMat),.]; RETP(YMat,XMat,piMat); ENDP; /* Procedure to turn the coefficient matrix of a VAR of the form y[t] = piMat'*x[t], where x[t] = y[t-1]|y[t-2]|...|y[t-r], into a coefficient matrix of a corresponding first order VAR. In addition the procedure will take a matrix of estimated VAR errors and return a matrix of corresponding errors for the first order VAR. */ PROC (2) = makeFOVAR(pimat,resids); LOCAL T,lagNo,varNo,rowNo,theta,errs; T = ROWS(resids); varNo = COLS(piMat); rowNo = ROWS(piMat); lagNo = rowNo/varNo; IF lagNo >= 2; theta = piMat'|(EYE(rowNo-varNo)~ZEROS(rowNo-varNo,varNo)); errs = resids~ZEROS(T,rowNo-varNo); ELSE; theta = piMat'; errs = resids; ENDIF; RETP(theta,errs); ENDP; /*****************Rolling.prg**********************************************************/ This is the program for figures 2 and 6. It uses the eviews workfile. After running the eviews program, the data from column 1,7,and 11 of _dfstat (a eviews matrix from the program output) are used to construct FIGURE 2. column 1=r3 column 7=r66 column 11=r114 After running the eviews program, the data from column 12,16,and 21 of _dfstat (a eviews matrix) are used to construct FIGURE 6. column 12=r6-r3 column 16=r54-r3 column 21=r114-r3 'this is the program file that creates the results for the rolling augmented DF tests ' load the data load "h:\thornton\gensaki\dan_data.wf1" smpl @all ' find size of workfile series _temp = 1 !length = @obs(_temp) delete _temp ' set fixed sample size !ssize = 78 ' initialize matrix to store results matrix(!length-!ssize+1,21) _coef matrix(!length-!ssize+1,21) _stderrs matrix(!length-!ssize+1,21) _dfstat ' run test regression for each subsample and store for !i = 1 to !i+!length-!ssize smpl @first+!i-1 @first+!i+!ssize-2 equation _equ.ls(n) d(r3) c r3(-1) d(r3(-1)) d(r3(-2)) d(r3(-3)) _coef(!i,1) = @coefs(2) _stderrs(!i,1) = @stderrs(2) _dfstat(!i,1)=_coef(!i,1)/_stderrs(!i,1) equation _equ.ls(n) d(r6) c r6(-1) _coef(!i,2) = @coefs(2) _stderrs(!i,2) = @stderrs(2) _dfstat(!i,2)=_coef(!i,2)/_stderrs(!i,2) equation _equ.ls(n) d(r18) c r18(-1) d(r18(-1)) d(r18(-2)) _coef(!i,3) = @coefs(2) _stderrs(!i,3) = @stderrs(2) _dfstat(!i,3)=_coef(!i,3)/_stderrs(!i,3) equation _equ.ls(n) d(r30) c r30(-1) _coef(!i,4) = @coefs(2) _stderrs(!i,4) = @stderrs(2) _dfstat(!i,4)=_coef(!i,4)/_stderrs(!i,4) equation _equ.ls(n) d(r42) c r42(-1) _coef(!i,5) = @coefs(2) _stderrs(!i,5) = @stderrs(2) _dfstat(!i,5)=_coef(!i,5)/_stderrs(!i,5) equation _equ.ls(n) d(r54) c r54(-1) _coef(!i,6) = @coefs(2) _stderrs(!i,6) = @stderrs(2) _dfstat(!i,6)=_coef(!i,6)/_stderrs(!i,6) equation _equ.ls(n) d(r66) c r66(-1) _coef(!i,7) = @coefs(2) _stderrs(!i,7) = @stderrs(2) _dfstat(!i,7)=_coef(!i,7)/_stderrs(!i,7) equation _equ.ls(n) d(r78) c r78(-1) d(r78(-1)) _coef(!i,8) = @coefs(2) _stderrs(!i,8) = @stderrs(2) _dfstat(!i,8)=_coef(!i,8)/_stderrs(!i,8) equation _equ.ls(n) d(r90) c r90(-1) _coef(!i,9) = @coefs(2) _stderrs(!i,9) = @stderrs(2) _dfstat(!i,9)=_coef(!i,9)/_stderrs(!i,9) equation _equ.ls(n) d(r102) c r102(-1) _coef(!i,10) = @coefs(2) _stderrs(!i,10) = @stderrs(2) _dfstat(!i,10)=_coef(!i,10)/_stderrs(!i,10) equation _equ.ls(n) d(r114) c r114(-1) _coef(!i,11) = @coefs(2) _stderrs(!i,11) = @stderrs(2) _dfstat(!i,11)=_coef(!i,11)/_stderrs(!i,11) equation _equ.ls(n) d(d6) c d6(-1) d(d6(-1)) _coef(!i,12) = @coefs(2) _stderrs(!i,12) = @stderrs(2) _dfstat(!i,12)=_coef(!i,12)/_stderrs(!i,12) equation _equ.ls(n) d(d18) c d18(-1) d(d18(-1)) _coef(!i,13) = @coefs(2) _stderrs(!i,13) = @stderrs(2) _dfstat(!i,13)=_coef(!i,13)/_stderrs(!i,13) equation _equ.ls(n) d(d30) c d30(-1) d(d30(-1)) _coef(!i,14) = @coefs(2) _stderrs(!i,14) = @stderrs(2) _dfstat(!i,14)=_coef(!i,14)/_stderrs(!i,14) equation _equ.ls(n) d(d42) c d42(-1) _coef(!i,15) = @coefs(2) _stderrs(!i,15) = @stderrs(2) _dfstat(!i,15)=_coef(!i,15)/_stderrs(!i,15) equation _equ.ls(n) d(d54) c d54(-1) _coef(!i,16) = @coefs(2) _stderrs(!i,16) = @stderrs(2) _dfstat(!i,16)=_coef(!i,16)/_stderrs(!i,16) equation _equ.ls(n) d(d66) c d66(-1) _coef(!i,17) = @coefs(2) _stderrs(!i,17) = @stderrs(2) _dfstat(!i,17)=_coef(!i,17)/_stderrs(!i,17) equation _equ.ls(n) d(d78) c d78(-1) d(d78(-1)) _coef(!i,18) = @coefs(2) _stderrs(!i,18) = @stderrs(2) _dfstat(!i,18)=_coef(!i,18)/_stderrs(!i,18) equation _equ.ls(n) d(d90) c d90(-1) d(d90(-1)) _coef(!i,19) = @coefs(2) _stderrs(!i,19) = @stderrs(2) _dfstat(!i,19)=_coef(!i,19)/_stderrs(!i,19) equation _equ.ls(n) d(d102) c d102(-1) _coef(!i,20) = @coefs(2) _stderrs(!i,20) = @stderrs(2) _dfstat(!i,20)=_coef(!i,20)/_stderrs(!i,20) equation _equ.ls(n) d(d114) c d114(-1) _coef(!i,21) = @coefs(2) _stderrs(!i,21) = @stderrs(2) _dfstat(!i,21)=_coef(!i,21)/_stderrs(!i,21) next