CALENDAR(M) 1960:1 all 2011:12 open data c:\work\holt2\COMMOD_PRIM_WB_a3.xls data(org=cols,format=xls) *table LABELS 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 # 'Maize' 'Wheat' 'Soybeans' 'Sorghum' 'Palmoil' 'Rice' 'Cotton' 'Coffee' 'Cocoa' $ 'Sugar' 'Beef' 'Logs' 'Rubber' 'Oil' 'NatGas' 'Coal' 'Freight' 'Fertilizer' $ 'Food' 'Energy' 'Grains' 'Tbill3' 'Nexrate' 'Rexrate' 'PPI' 'CPI' 'Real_YDIS' 'CORE_CPI' 'Climate' $ 'Ethanol' 'Oil_prod' @hpfilter(lambda=14400) real_ydis / hp_trend set cycle = real_ydis - hp_trend set inf = 400*(core_cpi/core_cpi{3}-1) set rtbill = tbill3 - inf{-1} com lmax = 36 set trend = t dec vector[integer] reglist compute reglist = || constant| trend || dec vector[series] sine(10) dsine(10) dec vector[series] cosine(10) dcosine(10) com header$ = || 'Series' | 'r(df)' | 't(df)' | 'Trend' |'nstar' | 'r(n)'| 't(n)' | 'rho_lm' | 'tau(lm)' |'kstar'| 'r(k)' |'t(k)'| 'lags' | 'T' || sou c:\work\holt2\mylagselect.src report(action=define,hlab=header$) dofor i = 3 5 16 19 23 26 31 32 39 * sta(noprint) [series]i ; com cap_T = %nobs , start = 1961:2+624-%nobs sta(noprint) [series]i ; com cap_T = %nobs , start = 1974:1 if i==32 { ; sta(noprint) [series]i ; com cap_T = %nobs , start = 1983:1 ; } do k = 1,5 set sine(k) start * = sin(2.*%pi*k*(t+1-start)/(%nobs-12)) ; dif sine(k) / dsine(k) set cosine(k) start * = cos(2.*%pi*k*(t+1-start)/(%nobs-12)) ; dif cosine(k) / dcosine(k) end do k set price = [series]i set y = log(100*(price/price(1996:1))/(ppi/ppi(1996:1))) if i == 26 ; set y = log(100*(price/price(1996:1))) if i == 39 ; set y = rtbill dif y start * dy @lagselect(crit=aic,print=0,maxlag=12,det=trend) y start * com lags = lagaic , trendflag = 1 *** Dickey-Fuller Test lin(noprint) dy ; # y{1} constant trend dy{1 to lags-1} if abs(%tstats(3))<1.64 { com trendflag = 0 lin(noprint) dy ; # y{1} constant dy{1 to lags-1} ; } com rho_df = %beta(1), tstat_df = %tstats(1) *** Fourier DF Test Cum com aic_min = 10000000. do n = 1,3 if n == 1 ; com reglist = || sine(1) | cosine(1) || if n > 1 ; enter(varying) reglist ; # reglist sine(n) cosine(n) lin(noprint) dy start * ; # y{1} constant trend dy{1 to lags-1} reglist compute aic = %nobs*log(%rss) + 2.*(%nreg) if (aic < aic_min); com aic_min = aic , nstar = n end do n do n = 1,nstar if n == 1 ; com reglist = ||sine(1) | cosine(1) || if n > 1 ; enter(varying) reglist ; # reglist sine(n) cosine(n) end do n lin(noprint) dy start * resids ; # y{1} constant trend dy{1 to lags-1} reglist if abs(%tstats(3)) < 1.64 { com trendflag = 0 lin(noprint) dy start * resids ; # y{1} constant dy{1 to lags-1} reglist ; } com rho_n = %beta(1), tstat_n = %tstats(1) *** Single k com aic_min = 10000000. compute reglist = || constant| trend || do k = 1,3 lin(noprint) dy start * ; # y{1} dy{1 to lags-1} sine(k) cosine(k) reglist compute aic = %nobs*log(%rss) + 2.*(%nreg) if (aic < aic_min); com aic_min = aic , kstar = k end do k lin(noprint) dy start * resids ; # y{1} constant trend dy{1 to lags-1} sine(kstar) cosine(kstar) if abs(%tstats(3)) < 1.64 { com trendflag = 0 lin(noprint) dy start * resids ; # y{1} constant dy{1 to lags-1} sine(kstar) cosine(kstar) ; } com rho_k = %beta(1), tstat_k = %tstats(1) * exc ; # sine(kstar) cosine{kstar) *** LM Fourier compute reglist = || constant || do n = 1,nstar enter(varying) reglist ; # reglist dsine(n) dcosine(n) end do n lin(noprint) dy start * resids ; # reglist set s_tilde = y - %beta(1)*t do n = 1,nstar set s_tilde = s_tilde - %beta(2*n)*sine(n) - %beta(2*n+1)*cosine(n) end do n com phi = s_tilde(start) set s_tilde = s_tilde - phi dif s_tilde / ds_tilde lin(noprint) dy start * ; # s_tilde{1} ds_tilde{1 to lags-1} reglist com tau_lm = %tstats(1) , rho_lm = %beta(1) , nobs = %nobs report(atcol=1) %L(i) rho_df tstat_df trendflag nstar rho_n tstat_n rho_lm tau_lm kstar rho_k tstat_k lags %datelabel(start) end dofor i report(action=show,window='Start Date')