PROC JOHANSEN * ======================================================================== * Johansen Tests for Cointegration * * Reference: S. Johansen and K. Juselius, "Maximum Likelihood Estimation * and Inference on Cointegration - with Applications to the Demand * for Money", OXFORD BULLETIN OF ECONOMICS AND STATISTICS, Vol 52, * 1990, pp. 169-210. * * Equation numbers refer to the above paper. * * Notes: * (1) The model includes a constant term and three seasonal dummies. * This is appropriate for quarterly time series. * (2) No restrictions on the constant term are imposed. This allows * for linear trends in the data. * * Critical values for the test statistics are tabulated in * Johansen and Juselius (1990), Table A2. * * TRACE TEST * Null hypothesis: No. of cointegrating vectors is less than or equal to r. * * 10 % critical values 5 % critical values * r p=2 p=3 p=4 p=5 r p=2 p=3 p=4 p=5 * ------------------------------- ------------------------------- * 4 6.7 4 8.1 * 3 6.7 15.6 3 8.1 17.8 * 2 6.7 15.6 28.4 2 8.1 17.8 31.3 * 1 6.7 15.6 28.4 45.2 1 8.1 17.8 31.3 48.4 * 0 15.6 28.4 45.2 66.0 0 17.8 31.3 48.4 70.0 * r = number of cointegrating vectors * p = number of time series * * MAXIMUM EIGENVALUE TEST * Null hypothesis: No. of cointegrating vectors is r. * Alternative: r+1 cointegrating vectors * * 10 % critical values 5 % critical values * r p=2 p=3 p=4 p=5 r p=2 p=3 p=4 p=5 * ------------------------------- ------------------------------- * 4 6.7 4 8.1 * 3 6.7 12.8 3 8.1 14.6 * 2 6.7 12.8 19.0 2 8.1 14.6 21.3 * 1 6.7 12.8 19.0 24.9 1 8.1 14.6 21.3 27.3 * 0 12.8 19.0 24.9 30.8 0 14.6 21.3 27.3 33.3 * * ===> WARNINGS * (1) The data is transformed to logarithms. If this is not desired then * change the command MATRIX X_=LOG(X_) to MATRIX X_=X_ * (2) If quarterly seasonal dummies are not required then change the * command MATRIX QD_=SEAS(T_,4) to GENR QD_=1 * * Use: * FILE PROC JOHANSEN * SAMPLE beg end * NLAG: lag k (k > 1) * VARS: list of time series * EXEC JOHANSEN * * Programmed by Diana Whistler, Revision: April, 2000 * E-mail: diana@shazam.econ.ubc.ca * ======================================================================== SET NOECHO SET NODOECHO SET NOOUTPUT COPY [VARS] X_ / TROW=1,$N * Take logs of the data MATRIX X_=LOG(X_) GEN1 P_=$COLS GEN1 T_=$ROWS * Generate seasonal dummy variables MATRIX QD_=SEAS(T_,4) *GENR QD_=1 SAMPLE 2 T_ * Generate first differences MATRIX DX_=X_-LAG(X_) * Allocate arrays to store results GEN1 NLAG_=[NLAG] IF1(NLAG_.LT.2) NLAG_=2 PRINT NLAG_ GEN1 NLL_=NLAG_-1 GEN1 KK_=P_*NLL_ DIM EA0_ T_ P_ EAK_ T_ P_ DXVEC_ T_ KK_ GEN1 BEG_=NLAG_ + 1 SAMPLE BEG_ T_ DO #=1,P_ * Generate NLAG-period lagged variables GENR LY#_=LAG(X_:#,NLAG_) ENDO * Set up a matrix of lagged variables to use as regressors GEN1 C1_=1 DO #=1,NLL_ GEN1 C2_=C1_+P_-1 GEN1 R1_=#+1 GEN1 R2_=T_-# COPY DX_ DXVEC_ / FROW=1;R2_ TROW=R1_;T_ FCOL=1;P_ TCOL=C1_;C2_ GEN1 C1_=C2_+1 ENDO * Obtain the residuals stated in Equation (3.6) and (3.7) DO #=1,P_ * Regress first differences on the lagged differences OLS DX_:# DXVEC_ QD_ / RESID=EA0_:# NOCONSTANT * Regress NLAG-period lags on the lagged differences OLS LY#_ DXVEC_ QD_ / RESID=EAK_:# NOCONSTANT ENDO GEN1 T1_=$N COPY EA0_ E0_ / FROW=BEG_;T_ TROW=1;T1_ FCOL=1;P_ TCOL=1;P_ COPY EAK_ EK_ / FROW=BEG_;T_ TROW=1;T1_ FCOL=1;P_ TCOL=1;P_ * Note: the MATRIX command ignores the current SAMPLE command * Do the calculations in Equation (3.9) MATRIX S00_=E0_'E0_/T1_ MATRIX S0K_=E0_'EK_/T1_ MATRIX SKK_=EK_'EK_/T1_ * Cholesky decomposition - SKK=CC' MATRIX C_=CHOL(SKK_) MATRIX CINV_=INV(C_) * Matrix B is a symmetric positive definite matrix MATRIX B_=CINV_*S0K_'INV(S00_)*S0K_*CINV_' * Get the eigenvalues of B (real and positive) in descending order MATRIX LAMBDA_=EIGVAL(B_) SAMPLE 1 P_ SORT LAMBDA_ GENR LMAX_=-T1_*LOG(1-LAMBDA_) * Construct likelihood ratio test statistics from Equation (4.8) GENR LTRACE_=-T1_*SUM(LOG(1-LAMBDA_)) GENR R_=P_-TIME(0) ** The variables analyzed are: PRINT VARS / NONAMES FORMAT(5X,F5.0,8X,F10.3,3X,F10.3) PRINT R_ LTRACE_ LMAX_ / FORMAT DELETE / ALL_ SET DOECHO SET OUTPUT SET ECHO PROCEND