adfall.m (1492B)
1 % ADFALL.m [rrho,rts]=adfall(y,names,maxlag,tyes,all) 2 % Calls the ADF procedure for a series of countries/lags 3 % y: TxK matrix T years, K countries 4 % names: String vector of names, Kx1 5 % maxlag: Max # of lags to include 6 % tyes: tyes=1 ==> include time trend 7 % all: all=0 ==> print only min(SIC) else print all 8 9 function [rrho,rts] = adfall(y,names,maxlag,tyes,all); 10 11 disp ' '; 12 disp '-----------------------------------------------------------------------'; 13 disp ' '; 14 if tyes; disp 'ADF UNIT ROOT TEST: Includes Time Trend'; 15 else; disp 'ADF UNIT ROOT TEST: No Time Trend'; end; 16 17 [T K] = size(y); 18 fmt = '%4.0f %8.4f %8.2f %8.4f %8.4f %8.4f %8.4f'; 19 rrho=zeros(K,1); 20 rts =zeros(K,1); 21 for i=1:K; 22 fprintf([names(i,:) ' ']); 23 yy=packr(y(:,i)); 24 Ty=length(yy); fprintf('(T= %2.0f',Ty); fprintf(') '); 25 if Ty ~= 0; 26 TF=Ty-maxlag; 27 xx=ones(Ty,1); 28 brow=2; 29 if tyes; 30 xx=[xx (1:Ty)']; 31 brow=3; 32 end; 33 rho=[]; tstat=[]; infc=[]; 34 for j=0:maxlag; 35 diary off; 36 [be ts ic ] = adf(yy,xx,j,TF); 37 diary on; 38 rho=[rho; be(brow)+1]; 39 tstat=[tstat; ts(brow)]; 40 infc =[infc; ic]; 41 end; % j=Lags 42 if all; 43 disp ' '; 44 fprintf(1,fmt,[(0:maxlag)' rho tstat infc]); disp ' '; 45 else; 46 [ic,k]=min(infc(:,1)); 47 fprintf(1,fmt,[k-1 rho(k) tstat(k) infc(k,1)]); 48 rrho(i)=rho(k); 49 rts(i) =tstat(k); 50 end; % if all 51 end; % if Ty~=0; 52 disp ' '; 53 end; % i=Countries 54 disp ' '; 55 disp '-----------------------------------------------------------------------'; 56 disp ' ';