PROC GRANGER SET NOECHO NODOECHO NOOUTPUT * ======================================================================== * Granger causality * * Programmed by Diana Whistler, Revision date: August 4, 1999 * E-mail: diana@shazam.econ.ubc.ca * ======================================================================== COPY [VARS] YMAT_ / TROW=1;$N GEN1 T_=$N MATRIX Y1_=YMAT_(0,1) MATRIX Y2_=YMAT_(0,2) DIM VY1_ T_ NLAG VY2_ T_ NLAG GEN1 BEG_=NLAG + 1 SAMPLE BEG_ T_ DO #=1,NLAG GENR YL_=LAG(Y1_,#) COPY YL_ VY1_ / FCOL=1;1 TCOL=#;# FROW=1;T_ TROW=1;T_ GENR YL_=LAG(Y2_,#) COPY YL_ VY2_ / FCOL=1;1 TCOL=#;# FROW=1;T_ TROW=1;T_ ENDO * H0: Y2 does not Granger-cause Y1 OLS Y1_ VY1_ VY2_ GEN1 NOBS_=$N GEN1 SU_=$SSE GEN1 SIGMA_=$SIG2 OLS Y1_ VY1_ GEN1 TEST1=($SSE-SU_)/(NLAG*SIGMA_) * H0: Y1 does not Granger-cause Y2 OLS Y2_ VY1_ VY2_ GEN1 SU_=$SSE GEN1 SIGMA_=$SIG2 OLS Y2_ VY2_ GEN1 SR_=$SSE GEN1 TEST2=($SSE-SU_)/(NLAG*SIGMA_) GEN1 DF1=NLAG GEN1 DF2=(NOBS_-2*NLAG-1) * Calculate a 5% critical value SAMPLE 1 1 GEN1 ALPHA_=0.05 DISTRIB ALPHA_ / TYPE=F DF1=DF1 DF2=DF2 INVERSE CRIT=CRIT05 * Calculate p-values DISTRIB TEST1 / TYPE=F DF1=DF1 DF2=DF2 CDF=CDF_ GEN1 PVAL1=1-CDF_ DISTRIB TEST2 / TYPE=F DF1=DF1 DF2=DF2 CDF=CDF_ GEN1 PVAL2=1-CDF_ DELETE / ALL_ SET ECHO DOECHO OUTPUT PROCEND