panadf.m (2818B)
1 % PANADF.m Panel Augmented Dickey Fuller tests... 2 % [rho,ts,tsll1,tsll2,ic]=panadf(y,lags,TF,detx); 3 % Generalized procedure following Levin and Lin 4 % 5 % detx=0 ==> Include nothing on RHS 6 % detx=1 ==> Include single intercept 7 % detx=2 ==> Include fixed effects 8 % detx=3 ==> Include fixed effects + common time trend 9 % detx=4 ==> Include fixed effects + individual time trends 10 % detx=5 ==> Include fixed effects + time dummies 11 % 12 % y=TxN matrix of data (T=time; N=# of countries) 13 % lags=# of extra lag terms to soak up serial correlation 14 % TF=fixed value of T to use in computing information criteria 15 % 16 % Sets prevest for OLS procedure... 17 18 function [rho,ts,tsll1,tsll2,ic]=panadf(y,lags,TF,detx); 19 20 [sy sylag] = panlag(y,lags+1,detx>=2); % Get demeaned lags? 21 [d1 d2] = panlag(delta(y),lags,detx>=2); % Get demeaned dlags? 22 rhs=[sylag(:,1) d2]; 23 [TT N] = size(y); 24 25 % No fixed effects needed since variables are demeaned ==> prevest=N in ols. 26 indv=['YLag '; vdummy('DYLag',lags)]; 27 prevest=0; 28 if detx==0; 29 tle='Panel ADF With No Deterministic Part'; 30 elseif detx==1; 31 rhs=[rhs ones(size(rhs,1),1)]; 32 indv=[indv; 'Constant']; 33 tle='Panel ADF + Constant'; 34 elseif detx==2; 35 prevest=N; 36 tle='Panel ADF + Fixed Effects'; 37 elseif detx==3; 38 prevest=N; 39 rhs=[rhs pantrend(y,lags+1,detx)]; 40 indv=[indv; 'CTrend ']; 41 tle='Panel ADF + Common Trend'; 42 elseif detx==4; 43 prevest=N; 44 rhs=[rhs pantrend(y,lags+1,detx)]; 45 indv=[indv; vdummy('T',N)]; 46 tle='Panel ADF + Individual Trends'; 47 elseif detx==5; 48 prevest=N; 49 td=pantrend(y,lags+1,detx); 50 rhs=[rhs td]; 51 indv=[indv; vdummy('T',size(td,2))]; 52 tle='Panel ADF + Time Dummies'; 53 end; 54 55 [u,NT,K,stdest,b,vcv] = ols(sy-sylag(:,1),rhs,tle,'Y',indv,prevest); 56 rho=b(1)+1; 57 ts = b(1)/sqrt(vcv(1,1)); 58 59 60 % Let's calculate the small-sample bias adjusted RHO also 61 T=NT/N; 62 if (detx<=3) | (detx==5); 63 rho = [rho rho+3/T]; 64 elseif detx==4; 65 rho = [rho rho+7.5/T]; 66 end; 67 68 69 disp ' '; 70 fprintf('Rho : %8.4f %8.4f',rho); disp ' '; 71 fprintf('TStat : %8.2f',ts); disp ' '; 72 73 % Schwarz Information Criteria: 74 ic = log(stdest^2)+lags*log(TF)/TF; 75 fprintf('SIC : %8.4f',ic); disp ' '; 76 77 % Now compute and print the Levin-Lin adjusted T-stat 78 % which should be N(0,1): sqrt(1.25)*t + sqrt(1.875*N) 79 80 if (detx<=3) | (detx==5); 81 tsll1 = sqrt(1.25)*ts+sqrt(1.875*N); 82 elseif detx==4; 83 tsll1 = sqrt(448/277)*(ts+sqrt(3.75*N)); 84 end; 85 fprintf('TStatLL1: %8.2f N=%3.0f',tsll1,N); disp ' '; 86 87 % Compute the higher order approximation from Appendix 2 88 if detx<=3; 89 tsll2 = (ts+sqrt(1.5*N)*(1+T^(-1)-2.5*T^(-2)-2.5*T^(-3)))/... 90 sqrt(0.8-2.4*T^(-1)-12*T^(-2)+36*T^(-3)+62.5*T^(-4)); 91 else; 92 tsll2 = 0; 93 end; 94 fprintf('TStatLL2: %8.2f',tsll2); disp ' '; 95 96 if detx==3; % let's return common trend + tstat in ic 97 K=K-prevest; 98 ic = [ic b(K) b(K)/sqrt(vcv(K,K))]; 99 end;