* Examining a Unit Root in GDP * * Keywords: * nonstationary, trend, unit root, gdp, kpss * * Description: * We test for a unit root in the U.S. real GDP with the KPSS test * * Author(s): * Noel Roy * Skif Pankov * * Source: * William H. Greene, Econometric Analysis - 7th Edition * Pearson International Edition, Chapter 21, Example 21.4 (page 998) * * Reading the data and naming variables, specifying to ignore the first * line read (TableF5-2.shd)year qtr realgdp realcons realinvs realgovt realdpi cpi m1 & i unemp pop pi realint / skiplines=1 * Generating log of real GDP genr y=log(realgdp) * Estimating time trend equation genr t=time(0) ols y t /resid=e gen1 n=\$n gen1 sse=\$sse * Estimating Newey-West estimate of sigma-squared * Set L=10 gen1 L=10 * Estimating correction factors gen1 nw=0 set nodoecho do !=1,L gen1 s=!+1 sample s n genr ee=e*lag(e,!) ?stat ee / sums=see gen1 nw=nw+(1-!/(L+1))*see(1)/n endo gen1 sig2=sse/n+2*nw print sig2 * Calculating KPSS statistic sample 1 n genr bige=e genr bige=e+lag(bige) genr bige2=bige**2 ?stat bige2 / sums=sbige2 gen1 kpss=sbige2(1)/n**2/sig2 print kpss * Repeating without trend ols y /resid=e gen1 sse=\$sse gen1 nw=0 do !=1,L gen1 s=!+1 sample s n genr ee=e*lag(e,!) ?stat ee/sums=see gen1 nw=nw+(1-!/(L+1))*see(1)/n endo gen1 sig2=sse/n+2*nw print sig2 SAMPLE 1 n genr bige=e genr bige=e+lag(bige) genr bige2=bige**2 ?stat bige2 / sums=sbige2 gen1 kpss=sbige2(1)/n**2/sig2 print kpss stop