* * Hamp599.prg * Cointegration analysis of consumption-income data, including tests on * coefficients of the cointegrating vector * cal(q) 1947 open data coninc.rat data(format=rats) 1947:1 1989:3 gyd82 gc82 * * Do data transformation * set cons = 100*log(gc82) set inc = 100*log(gyd82) graph(footer="Figure 19.5 PCE and PDI",key=upleft) 2 # cons # inc * * Unit root tests * @dfunit(det=trend,lags=6) inc @dfunit(det=trend,lags=6) cons * * Tests with hypothesized cointegrating vector * set z = cons - inc @dfunit(lags=6) z @ppunit(lags=6) z graph(footer="Figure 19.6 log(PCE)-log(PDI)") # z * * Tests with estimated cointegrating vector * linreg cons / coresids # constant inc linreg coresids / resids # coresids{1} mcov(lags=6,lwindow=newey) / resids # constant * * The MCOV produces a raw sum, which needs to be divided by the number of observations * to get the required "lambda**2" value. c0 can be obtained by dividing the sum of * squared residuals by the same number of observations. The sigma for rho and the standard * error of estimate can be pulled out of the regression variables. * * Note that the %NOBS variable will be equal to the number of observations in the AR(1) * regression, which will be T-1 in Hamilton's notation. * compute lambdasq=%cmom(1,1)/%nobs compute c0 =%rss/%nobs compute sigrho =%stderrs(1) compute sig =sqrt(%seesq) * compute zp=%nobs*(%beta(1)-1)-.5*(%nobs*sigrho/sig)**2*(lambdasq-c0) compute zt=sqrt(c0/lambdasq)*(%beta(1)-1)/sigrho-.5*(%nobs*sigrho/sig)*(lambdasq-c0)/sqrt(lambdasq) disp "Phillips-Ouliaris Tests" disp "Zp=" zp disp "Zt=" zt * * Testing hypotheses, pp 610-612. Run the cointegrating regression augmented with * leads and lags of the change in income, and compute the standard t-statistic * for the hypothesis of interest. The value of ttest here will be slightly * different from the one in the text, since this is computed using the full * precision, not just five digits. * clear resids set delinc = inc-inc{1} linreg cons / resids # constant inc delinc{-4 to 4} compute ttest=(%beta(2)-1)/%stderrs(2) * * Compute the correction for the t-statistic. * * This uses the lambda11 computed from a two lag autoregression. lambda11nw uses * a Newey-West type formula to compute another estimate of that quantity. The * latter isn't used here, but could be substituted in by just adding "nw" to the * end of lambda11 in the compute ttest=... instruction. * compute see=sqrt(%seesq) linreg resids # resids{1 2} compute lambda11=sqrt(%seesq)/(1-%sum(%beta)) mcov(lags=6,lwindow=newey) / resids # constant compute lambda11nw=sqrt(%cmom(1,1)/%nobs) compute ttest=ttest*see/lambda11 cdf normal ttest * * Testing trend coefficient=0 * set trend = t clear resids linreg cons / resids # constant inc trend delinc{-4 to 4} compute see=sqrt(%seesq) compute ttest=%beta(3)/%stderrs(3) linreg resids # resids{1 2} compute lambda11=sqrt(%seesq)/(1-%sum(%beta)) mcov(lags=6,lwindow=newey) / resids # constant compute lambda11nw=sqrt(%cmom(1,1)/%nobs) compute ttest=ttest*see/lambda11 cdf normal ttest