The code produces no result

Dear admin,

I try to implement Mr. Camacho's code to employ TAR panel unit root test, however the code does not produce the necessary linearity test statistics for my sample.  (however the code produces the necessary statistiscs for Camacho's data). Could you help me to obtain the test statistics? I am sending my data and the code:

 

629.9260 245.6520 1610.7871 119.3071 413.7835 1008.7248 9988.4958
646.6392 194.6582 1630.0888 121.8320 395.5001 1009.3884 10074.6631
686.4069 199.0067 1652.4759 41.8651 402.1966 978.2357 10682.9007
722.9602 141.2536 1531.3507 35.5229 370.7892 978.9876 11811.3980
684.4713 183.9022 592.2394 37.9461 212.5962 942.4158 11866.3395
702.4106 310.5648 644.5301 77.9709 150.8528 1019.5806 11706.8624
710.4717 379.2059 719.8293 122.8187 194.2729 1018.4913 12635.1197
764.8071 447.3785 880.4054 127.6980 238.9784 1136.2155 13505.5825
729.8240 547.2175 927.0268 145.5130 265.0761 1184.5059 11397.0590
830.7680 520.9555 1061.1892 165.7064 306.3353 1443.8545 12343.4074
886.7882 585.2202 1210.7738 191.5980 393.6730 1587.0015 13182.7437
881.8308 593.5863 1258.8451 201.3683 438.0635 1565.8312 13417.3979
901.1514 585.7895 1310.8613 218.2700 543.2442 1598.5744 13837.1460
920.5905 627.9028 1388.3268 254.9263 547.2827 1692.2894 13763.7523
975.4276 658.0915 1502.0870 286.8444 570.8059 1775.6473 14782.8892
1067.4517 726.1792 1593.4990 328.3597 650.5328 1788.2086 15166.7969
1045.5201 740.3249 1620.8131 348.6545 793.5364 1814.1809 14874.8725
1042.2049 738.7919 1621.1493 359.4890 789.7771 1831.6809 14889.3023
1036.5164 745.6247 1659.7026 391.4422 886.4408 1941.6594 15226.2293
1054.4541 789.1071 1810.4337 468.0577 1190.2191 2140.1610 15539.5625
1074.2951 863.4487 1878.9222 549.7633 1382.1788 2226.2625 15760.3016
1145.7044 932.5607 2039.3636 630.5602 1589.5319 2347.1808 16443.8653
1195.9823 1003.7664 2196.1767 701.6973 1833.9465 2459.2130 17252.5958
1307.0478 1101.7050 2280.8148 768.0644 2119.3036 2498.1310 18105.0958
1417.6643 1135.6935 2311.8082 818.1325 2334.2158 2587.2055 18757.3770
1490.3337 1170.4078 2247.2456 871.9153 2804.9474 2579.6332 19836.5762
1594.7458 1263.0193 2114.4947 960.5113 3338.6549 2618.4322 20793.2131
1671.6485 1332.2153 2179.3154 1045.2408 3887.8538 2671.1623 22308.4938
1747.5926 1411.3488 2277.8852 1120.4580 4436.5657 2785.6203 23145.8354
1830.4471 1548.8589 2429.9221 1209.4747 4620.2715 2916.8233 23530.2859
1898.0782 1661.1218 2533.9355 1259.9289 4852.0960 2990.3250 23800.9366
1988.4760 1783.9731 2615.5738 1331.0753 5060.4846 2993.7897 24585.9100
2150.7899 1962.0977 2736.4807 1428.5633 5477.7475 3174.9116 25340.9283
2220.5986 1893.4654 2666.7323 1430.4882 5370.0630 2977.2044 24053.7217
2111.6817 1845.5792 2662.5769 1400.8777 5292.4545 2893.0299 22827.9282
2154.3268 2014.0039 2767.1819 1508.0991 5347.9154 2913.5302 23921.1586
2230.6448 1983.9183 2809.3827 1532.9734 5475.7093 2979.9945 24395.4769
2271.9833 2121.1235 2922.2385 1572.8559 5478.4317 3040.1867 24409.6689
2352.0445 2121.6303 3024.7145 1689.8275 5538.3341 3152.7087 24068.7771
2396.7671 2084.8588 3018.2170 1694.8206 5391.0491 2940.3938 22970.8399
2347.4597 1988.0701 2931.5001 1669.4272 5108.3057 2844.8884 22647.4894
2108.6389 1965.1542 2864.9315 1676.2346 4833.8855 2827.9828 21313.8580
2042.8571 1960.6603 2874.6581 1657.5851 4696.2567 2837.7205 21141.8970
2119.2728 1935.0959 2887.9166 1683.2110 4761.5871 2805.2878 21911.9916
2093.9072 1913.0842 2907.0305 1789.6623 4467.8182 2903.2029 21567.8991
2090.3321 1890.6142 2948.7538 1849.6561 4312.6553 3004.6938 21324.3185
2147.1284 1929.7128 2994.0829 1983.5021 4278.2644 3118.4717 21719.9461
2222.6938 1953.2726 3016.7523 2002.7415 4439.1699 3198.6998 22383.3163
2200.1615 1986.3006 2963.3047 1983.5145 4412.1673 3239.4827 22008.0716
2108.6248 2000.9194 2925.4038 1994.3912 4119.3212 3234.3411 21227.5552
2028.5567 2048.3351 2738.6563 2056.8329 4077.0552 3138.0115 20841.0475
2039.0534 2031.5329 2579.5745 2091.5181 3938.8823 3086.4570 20983.0088
2044.0456 1928.9677 2492.6848 1999.3599 3768.1811 2915.8854 20932.2345
2132.3809 1866.8323 2303.0156 1905.1690 3745.3011 2748.4497 20653.0656
2147.0384 1822.2902 2274.9949 1883.1336 3741.4546 2577.0370 20346.3384
2229.7272 1799.0639 2177.2171 1838.1416 3732.0426 2482.7736 20027.9820
2368.9070 1732.0343 2077.5903 1761.1967 3673.9552 2276.5712 20103.9380
2473.5964 1765.4281 2014.8669 1628.8460 3479.8131 2172.6210 19852.2196
2552.9304 1710.2950 1984.3504 1579.0295 3472.9366 2029.5235 18613.7093
2531.2799 1657.2370 1930.5757 1482.3560 3484.6024 1951.5576 18453.1734
2453.4437 1617.2380 1852.5947 1457.8718 3421.9118 1889.1358 17864.3726
2403.9033 1580.8315 1775.5144 1401.7201 3384.3319 1778.0367 16996.8010
2365.5515 1538.1966 1709.1323 1390.1547 3322.4634 1772.7952 16372.4376
2230.7395 1507.5868 1633.8276 1344.5816 3192.0311 1721.5809 16018.8777
2183.2636 1457.6868 1561.3130 1286.4909 3109.5626 1721.7290 15346.1696
2044.6654 1374.3704 1549.5517 1218.9006 3066.0748 1685.1655 14850.3201
2067.7341 1314.1152 1479.0469 1162.3801 3014.6710 1604.4239 14158.2754
1999.0974 1215.1043 1404.1980 1080.5079 2744.3522 1392.3961 12959.3697
1883.9061 1132.2905 1306.1974 980.8093 2498.1669 1201.2736 11947.0507
1890.2907 1113.8390 1331.4087 944.8041 2475.3268 1177.7844 11124.9905
1849.3037 1057.7242 1314.7371 906.8324 2453.7368 1091.7296 11256.1638
1768.2053 1026.3015 1280.8072 846.7015 2464.7407 1121.6645 10773.7801
1724.8388 1014.9196 1286.0988 796.5446 2449.8479 1063.7468 10415.4596
1680.6426 942.3183 1250.1739 779.1164 2342.6311 988.7881 10015.4499
1628.2186 917.6094 1231.6624 760.0835 2199.1733 966.9503 9472.0982
1602.6453 875.5295 1197.5688 739.3343 2112.2917 875.8521 8541.2173
1641.3310 839.8702 1160.0996 689.6509 2059.1599 843.5877 8118.0897
1646.0184 792.2391 1071.7035 668.7309 1972.0042 799.4644 7832.2734
1593.7569 744.7675 986.0675 621.2476 1896.9192 752.6900 7556.3346

 

 

@ Arielle Beyaert and Maximo Camacho
www.um.es/econometria/Maximo
February, 13th 2006 @

@ This GAUSS file generalizes Evans-Karras test as follows:
1) TAR estimates:
D(Znt) = [C1n + B1n (Znt-1) + B1n(L)D(Znt-1)]*I1t
[C2n + B2n (Znt-1) + B2n(L)D(Znt-1)]*I2t + Ent
gnt=Ynt-Yt, Ent ~ N(0,Vn)
I1t = 1 if TVt-d < Th, I2t = 1 if TV-d >= Th
TVt=gnt-gnt-m for some n and 0<m<=p
2) Linearity test:
Ho: C1n=C2n, B1n=B2n, B1n(L)=B2n(L) (line)
Ha: no Ho (TAR)
if Ho then goto Evans-Karras
if Ha then goto TAR Evans-Karras
Test statistics: LR = -2*(lnLo-lnLa)
3) Test of convergence:
Ho: B1=B2=0 (no conv)
Ha1: B1<0, B2<0
Ha2a: B1<0, B2=0
Ha2b: B1=0, B2<0
Test statistics: t1
Test statistics: t2
Test statistics: R2=t1^2+t2^2
4) Test of absolute conv. vs. relative conv.:
Ho: C1n=C2n (absolute conv)
Ha: no Ho (relative convergence)
phi=[sum tsta(C1n)^2 + sum tsta(C1n)^2]/(2*N-1) @

@ Quote the paper as:
Beyaert, A. and Camacho, M. 2008. TAR panel unit root tests and real convergence:
an application to the EU enlargement process. In Review of Development Economics 12: 668–681, @

new;cls;
format/rd 8,4;
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ADJUST CONTROL SPECIFICATIONS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
p=1; @ Maximum lag length of Bn(L) @
outp=1; @ outp=0 for no output files @
maxboot=1000; @ Maximum number of bootstraps @
seed=1; @ seed in bootstrap @
simuline=0; @ 0 to skip bootstrap simulations of 2) @
simuro=0; @ 0 to skip bootstrap simulations of 3) @
simudelta=0; @ 0 to skip bootstrap simulations of 4) @
vinima=1; @ vinima=1 to select initial values with MA @
reta=30; @ maxlag in MA to compute initial values @
grafico=1; @ grafico=0 to skip graphs @
minper=0.1; @ minimum percentage of obs in ecah regime @

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LOADING DATA IN LOGS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
load data[79,7]=data_.txt;
data=100*ln(data);
N=cols(data); @ N is the number of countries @
datam=meanc(data');
g=(data-datam);
dg=g[2:rows(g),.]-g[1:rows(g)-1,.];
g1=g[1:rows(g)-1,.];
g=g[2:rows(g),.];
T=rows(g);
T1=T-1;
tef=T-p;
tef1=tef-1;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHOOSING TV AND d
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
tope=tef1*p*n;
contar=1;
vmat=zeros(tef1,p*N);
thmat=zeros(tef1,p*N);
Nmat=zeros(tef1,p*N);
Nit=1;
do while Nit<=N;
mit=1;
do while mit<=p;
TVit=g[p+1:T,Nit]-g[p+1-mit:T-mit,Nit];
TVit1=TVit[1:tef1];
ite=1;
do while ite<=tef1;
cls;
"Choosing transition variable and threshold";
"Iteration number ";;contar;;"of ";;tope;
Thit=TVit1[ite];
{SSRit,theta,vtheta,La}=panelTARfun(TVit1,Thit,dg[2:T,.],g1[2:T,.]);
Thmat[ite,(Nit-1)*p+mit]=Thit;
Nmat[ite,(Nit-1)*p+mit]=Nit;
vmat[ite,(Nit-1)*p+mit]=SSRit/tef1;
contar=contar+1;
ite=ite+1;
endo;
mit=mit+1;
endo;
Nit=Nit+1;
endo;
cls;
Thvec=diag(Thmat[minindc(vmat),.]);
indi=minindc(minc(vmat));
Th=Thvec[indi];
Nth=Nmat[1,indi];
m=indi-(Nth-1)*p;
TV=g[p+1:T,Nth]-g[p+1-m:T-m,Nth];
TV1=TV[1:tef1];
I1=TV1.<Th;
perc=100*sumc(I1)/tef1;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Graph of TAR estimation
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
if grafico ne 0;
library pgraph;graphset;
pqgwin many;
throw=th*ones(rows(tv1),1);
xy(seqa(1,1,rows(data)),data);
xy(seqa(1,1,rows(TV1)),TV1~throw);
endif;
output file=ue9.out reset;
TV1;
output off;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TAR estimation
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
{SSR,theta,vtheta,La}=panelTARfun(TV1,Th,dg[2:T,.],g1[2:T,.]);
ra=rows(theta);
setheta=sqrt(diag(vtheta));

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Evans-Karras lineal estimates
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
{beta,vbeta,L0}=panelEKfun(dg[2:T,.],g1[2:T,.],p);
r0=rows(beta);

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Linearity test
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
LR1=-2*(L0-La);
pv_LR1=cdfchic(LR1,ra-r0);

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Test 1: convergence vs no convergence
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
{SSR1,beta1,vbeta1}=roTARfun(TV1,Th,dg[2:T,.],g1[2:T,.]);
@imposes one ro each regime@
rb1=rows(beta1);
t_ro1=beta1[N+1]/sqrt(vbeta1[N+1]);
pv_ro1=CDFN(t_ro1);
N2=N+1+N*p+N;
t_ro2=beta1[N2+1]/sqrt(vbeta1[N2+1]);
pv_ro2=CDFN(t_ro2);
R2=t_ro1^2+t_ro2^2;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Test 2: absolute conv. vs relative conv.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
{SSR2,beta2,vbeta2,La2}=panelTARfun(TV1,Th,dg[2:T,.],g1[2:T,.]);
rb2=rows(beta2);
F_delta1a=sumc((beta2[1:N]./sqrt(vbeta2[1:N]))^2)/(N-1);
pv_delta1a=CDFFC(F_delta1a,N-1,(N-1)*(T-p-2));
N2=2*N+N*p;
F_delta1b=sumc((beta2[N2+1:N2+N]./sqrt(vbeta2[N2+1:N2+N]))^2)/(N-1);
pv_delta1b=CDFFC(F_delta1b,N-1,(N-1)*(T-p-2));
F_delta1=((N-1)*F_delta1a+(N-1)*F_delta1b)/(2*N-1);
pv_delta1=CDFFC(F_delta1,2*N-1,(2*N-1)*(T-p-2));

if simuline ne 0;
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Unrestricted bootstrap of linearity test
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*STEP 1: Obtain params and resids under linearity*/
{beta0,resi0}=resifun1(dg,g1,p);
mresi0=meanc(resi0)';
resist0=resi0-mresi0; @ resi0 with zero mean @

/*STEP 2: Resample resist0 and generate series*/
LR1boot=zeros(maxboot,1);
t_ro1boot=zeros(maxboot,1);
t_ro2boot=zeros(maxboot,1);
R2boot=zeros(maxboot,1);

boot=1;
do while boot<=maxboot;
cls;"Bootstrap of linearity UNRESTRICTED test";
" iteration ";;boot;;"of ";;maxboot;"";
index=ceil(rndus(rows(resist0),1,seed)*rows(resist0));
resiboot=resist0[index,.];
{dgboot,g1boot}=gendgfun1(resiboot,beta0);

/*STEP 3: Compute the bootstrapped LR test */
{S1,th1,vh1,Labt}=panelTARfun(TV1,Th,dgboot[2:T,.],g1boot[2:T,.]);
{b1,vb1,L0bt}=panelEKfun(dgboot[2:T,.],g1boot[2:T,.],p);
LR1boot[boot]=-2*(L0bt-Labt);

seed=seed+1;
boot=boot+1;
endo;

LR1sort=sortc(LR1boot,1); @ this is to compute the p-value @
LR1nece=LR1sort.<LR1;
pvbt_LR1=1-sumc(LR1nece)/maxboot;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Restricted bootstrap of linearity test
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*STEP 1: Obtain params and resids under linearity*/
{beta0,resi0}=resifun2(dg,g1,p);
mresi0=meanc(resi0)';
resist0=resi0-mresi0; @ resi0 with zero mean @

/*STEP 2: Resample resist0 and generate series*/
LR2boot=zeros(maxboot,1);
boot=1;
do while boot<=maxboot;
cls;"Bootstrap of linearity RESTRICTED test";
" iteration ";;boot;;"of ";;maxboot;"";
index=ceil(rndus(rows(resist0),1,seed)*rows(resist0));
resiboot=resist0[index,.];
{dgboot,g1boot}=gendgfun2(resiboot,beta0);

/*STEP 3: Compute the bootstrapped LR test */
{S2,th2,vh2,Labt}=panelTARfun(TV1,Th,dgboot[2:T,.],g1boot[2:T,.]);
{b2,vb2,L0bt}=panelEKfun(dgboot[2:T,.],g1boot[2:T,.],p);
LR2boot[boot]=-2*(L0bt-Labt);

/*STEP 3': computes p-value of unit root tests */
if simuro ne 0;
{S3,b3,v3}=roTARfun(TV1,Th,dgboot[2:T,.],g1boot[2:T,.]);
t_ro1boot[boot]=b3[N+1]/sqrt(v3[N+1]);
t_ro2boot[boot]=b3[N2+1]/sqrt(v3[N2+1]);
R2boot[boot]=t_ro1boot[boot]^2+t_ro2boot[boot]^2;
endif; @ ends bootstrap of unit root test simulations @

seed=seed+1;
boot=boot+1;
endo;

LR2sort=sortc(LR2boot,1); @ this is to compute the p-value @
LR2nece=LR2sort.<LR1;
pvbt_LR2=1-sumc(LR2nece)/maxboot;

t_ro1sort=sortc(t_ro1boot,1);
t_ro1nece=t_ro1sort.<t_ro1;
pvbt_ro1=sumc(t_ro1nece)/maxboot;

t_ro2sort=sortc(t_ro2boot,1);
t_ro2nece=t_ro2sort.<t_ro2;
pvbt_ro2=sumc(t_ro2nece)/maxboot;

R2sort=sortc(R2boot,1);
R2nece=R2sort.<R2;
pvbt_R2=1-sumc(R2nece)/maxboot;

endif; @ ends bootstrap of linearity test simulations @

if simudelta ne 0;
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bootstrap of conv absolute/relative
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*STEP 1: Estimate equations imposing C=0 whatever B in lineal*/
{betad0,resid0}=resideltafun(dg,g1,p);
mresid0=meanc(resid0)';
residst0=resid0-mresid0; @ resid0 with zero mean @
/*STEP 2: Resample resist0 and generate series*/
F_deltabt1=zeros(maxboot,1);
F_deltabt1a=zeros(maxboot,1);
F_deltabt1b=zeros(maxboot,1);
boot=1;
do while boot<=maxboot;
cls;"Bootstrap of delta iteration delta tests";
" iteration ";;boot;;"of ";;maxboot;"";
index=ceil(rndus(rows(residst0),1,seed)*rows(residst0));
resiboot=residst0[index,.];
{dgboot,g1boot}=gendgdelfun(resiboot,betad0);
/*STEP 3: Compute the bootstrapped F tests*/
{SSR2bt,beta2bt,vbeta2bt,La2bt}=panelTARfun(TV1,Th,dgboot[2:T,.],g1boot[2:T,.]);
F_deltabt1a[boot]=sumc((beta2bt[1:N]./sqrt(vbeta2bt[1:N]))^2)/(N-1);
N2=2*N+N*p;
F_deltabt1b[boot]=sumc((beta2bt[N2+1:N2+N]./sqrt(vbeta2bt[N2+1:N2+N]))^2)/(N-1);
F_deltabt1[boot]=((N-1)*F_deltabt1a[boot]+(N-1)*F_deltabt1b[boot])/(2*N-1);

seed=seed+1;
boot=boot+1;
endo;

Fsort1a=sortc(F_deltabt1a,1);
Fnece1a=Fsort1a.<F_delta1a;
pvbt_delta1a=1-sumc(Fnece1a)/maxboot;

Fsort1b=sortc(F_deltabt1b,1);
Fnece1b=Fsort1b.<F_delta1b;
pvbt_delta1b=1-sumc(Fnece1b)/maxboot;

Fsort1=sortc(F_deltabt1,1);
Fnece1=Fsort1.<F_delta1;
pvbt_delta1=1-sumc(Fnece1)/maxboot;

endif;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
OUTPUTS
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
if outp ne 0;
cls;
output file=results.out reset;
"Results of threshold Evans-Karras estimates:";"";
" 1) TAR estimates";
" D(Znt) = [C1n + B1n (Znt-1) + B1n(L)D(Znt-1)]*I1t";
" [C2n + B2n (Znt-1) + B2n(L)D(Znt-1)]*I2t + Ent";
" gnt=Ynt-Yt, Ent ~ N(0,Vn) ";
" p = ";;p;
" bootstrap iterations ";;maxboot;
" minimum % observations in each regime: ";;minper*100;"";
" Transition variable";
" n = ";;Nth;
" m = ";;m;
" Threshold Th = ";;Th;
" % observations in first regime: 100*(TV.<Th)= ";;perc;"";
" 2) Linearity test:";
" Ho: C1n=C2n, B1n=B2n, B1n(L)=B2n(L) (line)";
" Ha: no Ho (TAR)";
" if Ho then goto Evans-Karras";
" if Ha then goto TAR Evans-Karras";"";
" Test statistics: LR = -2*(lnLo-lnLa) = ";;LR1;
" p-value ";;pv_LR1;
if simuline ne 0;
" Unrestricted Bootstrap p-value ";;pvbt_LR1;
" Restricted Bootstrap p-value ";;pvbt_LR2;
endif;"";
" 3) Test of convergence:";
" Ho: B1=B2=0 (no conv)";
" Ha1: B1<0, B2<0";
" Ha2a: B1<0, B2=0";
" Ha2b: B1=0, B2<0";"";
" Test statistics: t1 = ";;t_ro1;
" p-value ";;pv_ro1;
if simuline ne 0;
" Bootstrap p-value ";;pvbt_ro1;
endif;
" Test statistics: t2 = ";;t_ro2;
" p-value ";;pv_ro2;
if simuline ne 0;
" Bootstrap p-value ";;pvbt_ro2;
endif;
" Test statistics: R2 = t1^2+t2^2 = ";;R2;
if simuline ne 0;
" Bootstrap p-value ";;pvbt_R2;
endif;"";
" 4) Test of absolute conv. vs. relative conv.:";
" Ho1: C1n=C2n=0 (absolute conv)";
" Ha1: C1n=0 (absolute conv in first regime)";
" Ha2: C2n=0 (absolute conv in second regime)";
" Ha3: no Ho";
" phi1 = [sum tsta(C1n)^2 + sum tsta(C2n)^2]/(2*N-1)";
" phi1a = [sum tsta(C1n)^2]/(N-1)";
" phi1b = [sum tsta(C2n)^2]/(N-1)";"";
" Test statistics phi1a = ";;F_delta1a;
" p-value ";;pv_delta1a;
if simudelta ne 0;
" Bootstrap p-value ";;pvbt_delta1a;
endif;
" Test statistics phi1b = ";;F_delta1b;
" p-value ";;pv_delta1b;
if simudelta ne 0;
" Bootstrap p-value ";;pvbt_delta1b;
endif;
" Test statistics phi1 = ";;F_delta1;
" p-value ";;pv_delta1;
if simudelta ne 0;
" Bootstrap p-value ";;pvbt_delta1;
endif;
output off;
endif;

/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SOME PROCEDURES HERE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
proc(4)=panelTARfun(TVn,Thn,dgn,g1n);
local rdzm,y,x,unos,x1,x2,itc,itp,be,en,em,like,I1n,I2n,
I1m,I2m,e2,vari1,vari2,ivari1,ivari2,bes,ens,xxi,dvari2;
I1n=TVn.<Thn;
I2n=ones(tef1,1)-I1n;
if sumc(I1n)<ceil(minper*tef1);
e2=1e+10;bes=0;like=0;xxi=0;goto labb;
elseif sumc(I2n)<ceil(minper*tef1);
e2=1e+10;bes=0;like=0;xxi=0;goto labb;
endif;
y=zeros(tef1*N,1);
unos=zeros(tef1*N,N);
x1=zeros(tef1*N,N);
x2=zeros(tef1*N,N*p);
I1m=I1n;
I2m=I2n;
itc=1;
do while itc<=N;
if itc>1;
I1m=I1m|I1n;
I2m=I2m|I2n;
endif;
y[(itc-1)*tef1+1:itc*tef1]=dgn[p+1:T1,itc];
unos[(itc-1)*tef1+1:itc*tef1,itc]=ones(tef1,1);
x1[(itc-1)*tef1+1:itc*tef1,itc]=g1n[p+1:T1,itc];
itp=1;
do while itp<=p;
x2[(itc-1)*tef1+1:itc*tef1,(itc-1)*p+itp]=
dgn[p-itp+1:T1-itp,itc];
itp=itp+1;
endo;
itc=itc+1;
endo;
x=unos~x1~x2;
x1=x.*I1m;
x2=x.*I2m;
x=x1~x2;
be=inv(x'x)*x'y;
en=y-x*be;
em=en[1:tef1];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef1+1:itc*tef1];
itc=itc+1;
endo;
vari1=em'em/tef1;
ivari1=inv(vari1);
vari2=vari1.*.eye(tef1);
ivari2=ivari1.*.eye(tef1);
xxi=inv(x'ivari2*x);
bes=xxi*x'ivari2*y;
en=y-x*bes;
e2=en'ivari2*en;
dvari2=det(vari1)^tef1;
@like=((2*pi)^(-tef*N/2))*(dvari2^(-1/2))*exp(-(1/2)*en'ivari2*en);@
like=-(tef1*N/2)*ln(2*pi)-(en'ivari2*en/2)-ln(dvari2)/2;
labb:
retp(e2,bes,diag(xxi),like);
endp;

proc(3)=panelEKfun(dzm,z1m,pmax);
local rdzm,y,x,unos,x1,x2,itc,itp,be,en,em,like,
vari1,vari2,ivari1,ivari2,bes,ens,xxi,dvari2;
rdzm=rows(dzm);
y=zeros(tef1*N,1);
unos=zeros(tef1*N,N);
x1=zeros(tef1*N,N);
x2=zeros(tef1*N,N*pmax);
itc=1;
do while itc<=N;
y[(itc-1)*tef1+1:itc*tef1]=dzm[pmax+1:rdzm,itc];
unos[(itc-1)*tef1+1:itc*tef1,itc]=ones(tef1,1);
x1[(itc-1)*tef1+1:itc*tef1,itc]=z1m[pmax+1:rdzm,itc];
itp=1;
do while itp<=pmax;
x2[(itc-1)*tef1+1:itc*tef1,(itc-1)*pmax+itp]=
dzm[pmax-itp+1:rdzm-itp,itc];
itp=itp+1;
endo;
itc=itc+1;
endo;
x=unos~x1~x2;
be=inv(x'x)*x'y;
en=y-x*be;
em=en[1:tef1];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef1+1:itc*tef1];
itc=itc+1;
endo;
vari1=em'em/tef1;
ivari1=inv(vari1);
vari2=vari1.*.eye(tef1);
ivari2=ivari1.*.eye(tef1);
xxi=inv(x'ivari2*x);
bes=xxi*x'ivari2*y;
en=y-x*bes;
dvari2=det(vari1)^tef1;
@like=((2*pi)^(-tef*N/2))*(dvari2^(-1/2))*exp(-(1/2)*en'ivari2*en);@
like=-(tef1*N/2)*ln(2*pi)-(en'ivari2*en/2)-ln(dvari2)/2;
retp(bes,diag(xxi),like);
endp;

proc(3)=roTARfun(TVn,Thn,dgn,g1n);
local rdzm,y,x,unos,x1,x2,itc,itp,be,en,em,I1n,I2n,
I1m,I2m,e2,vari1,vari2,ivari1,ivari2,bes,ens,xxi;
I1n=TVn.<Thn;
I2n=ones(tef1,1)-I1n;
y=zeros(tef1*N,1);
unos=zeros(tef1*N,N);
x1=zeros(tef1*N,1);
x2=zeros(tef1*N,N*p);
I1m=I1n;
I2m=I2n;
itc=1;
do while itc<=N;
if itc>1;
I1m=I1m|I1n;
I2m=I2m|I2n;
endif;
y[(itc-1)*tef1+1:itc*tef1]=dgn[p+1:T1,itc];
unos[(itc-1)*tef1+1:itc*tef1,itc]=ones(tef1,1);
x1[(itc-1)*tef1+1:itc*tef1]=g1n[p+1:T1,itc];
itp=1;
do while itp<=p;
x2[(itc-1)*tef1+1:itc*tef1,(itc-1)*p+itp]=
dgn[p-itp+1:T1-itp,itc];
itp=itp+1;
endo;
itc=itc+1;
endo;
x=unos~x1~x2;
x1=x.*I1m;
x2=x.*I2m;
x=x1~x2;
be=inv(x'x)*x'y;
en=y-x*be;
em=en[1:tef1];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef1+1:itc*tef1];
itc=itc+1;
endo;
vari1=em'em/tef1;
ivari1=inv(vari1);
vari2=vari1.*.eye(tef1);
ivari2=ivari1.*.eye(tef1);
xxi=inv(x'ivari2*x);
bes=xxi*x'ivari2*y;
en=y-x*bes;
e2=en'ivari2*en;
retp(e2,bes,diag(xxi));
endp;

proc(2)=resifun1(dzm,z1m,pmax); @ Imposes linearity @
local rdzm,y,x,unos,x1,x2,itc,itp,be,en,em,
vari1,vari2,ivari1,ivari2,bes,ens,xxi;
rdzm=rows(dzm);
y=zeros(tef*N,1);
unos=zeros(tef*N,N);
x1=zeros(tef*N,N);
x2=zeros(tef*N,N*pmax);
itc=1;
do while itc<=N;
y[(itc-1)*tef+1:itc*tef]=dzm[pmax+1:rdzm,itc];
unos[(itc-1)*tef+1:itc*tef,itc]=ones(tef,1);
x1[(itc-1)*tef+1:itc*tef,itc]=z1m[pmax+1:rdzm,itc];
itp=1;
do while itp<=pmax;
x2[(itc-1)*tef+1:itc*tef,(itc-1)*pmax+itp]=
dzm[pmax-itp+1:rdzm-itp,itc];
itp=itp+1;
endo;
itc=itc+1;
endo;
x=unos~x1~x2;
be=inv(x'x)*x'y;
en=y-x*be;
em=en[1:tef];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef+1:itc*tef];
itc=itc+1;
endo;
vari1=em'em/tef;
ivari1=inv(vari1);
vari2=vari1.*.eye(tef);
ivari2=ivari1.*.eye(tef);
xxi=inv(x'ivari2*x);
bes=xxi*x'ivari2*y;
en=y-x*bes;
em=en[1:tef];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef+1:itc*tef];
itc=itc+1;
endo;
retp(bes,em);
endp;

proc(2)=gendgfun1(ebt,ben);
local dggen,dggen1,ggen,g1gen,itf,itc,it;
dggen=zeros(T,N);
ggen=zeros(T+1,N);
ggen[1,.]=g[1,.];
dggen[1:p,.]=dg[1:p,.];
itc=1;
do while itc<=N;
itf=p+1;
do while itf<=T;
dggen1=zeros(2*N+N*p,1);
dggen1[itc]=1;
dggen1[N+itc]=ggen[itf-1,itc];
dggen1[2*N+(itc-1)*p+1:2*N+itc*p]=
rev(dggen[itf-p:itf-1,itc]);
dggen[itf,itc]=dggen1'ben+ebt[itf-p,itc];
itf=itf+1;
endo;
it=2;
do while it<=T+1;
ggen[it,itc]=dggen[it-1,itc]+ggen[it-1,itc];
it=it+1;
endo;
itc=itc+1;
endo;
g1gen=ggen[1:T,.];
retp(dggen,g1gen);
endp;

proc(2)=resifun2(dzm,z1m,pmax); @ Imposes linearity @
local rdzm,y,x,unos,x2,itc,itp,be,en,em,
vari1,vari2,ivari1,ivari2,bes,ens,xxi;
rdzm=rows(dzm);
y=zeros(tef*N,1);
unos=zeros(tef*N,N);
x2=zeros(tef*N,N*pmax);
itc=1;
do while itc<=N;
y[(itc-1)*tef+1:itc*tef]=dzm[pmax+1:rdzm,itc];
unos[(itc-1)*tef+1:itc*tef,itc]=ones(tef,1);
itp=1;
do while itp<=pmax;
x2[(itc-1)*tef+1:itc*tef,(itc-1)*pmax+itp]=
dzm[pmax-itp+1:rdzm-itp,itc];
itp=itp+1;
endo;
itc=itc+1;
endo;
x=unos~x2;
be=inv(x'x)*x'y;
en=y-x*be;
em=en[1:tef];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef+1:itc*tef];
itc=itc+1;
endo;
vari1=em'em/tef;
ivari1=inv(vari1);
vari2=vari1.*.eye(tef);
ivari2=ivari1.*.eye(tef);
xxi=inv(x'ivari2*x);
bes=xxi*x'ivari2*y;
en=y-x*bes;
em=en[1:tef];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef+1:itc*tef];
itc=itc+1;
endo;
retp(bes,em);
endp;

proc(2)=gendgfun2(ebt,ben);
local dggen,dggen1,ggen,g1gen,itf,itc,it;
dggen=zeros(T,N);
ggen=zeros(T+1,N);
ggen[1,.]=g[1,.];
dggen[1:p,.]=dg[1:p,.];
itc=1;
do while itc<=N;
itf=p+1;
do while itf<=T;
dggen1=zeros(N+N*p,1);
dggen1[itc]=1;
dggen1[N+(itc-1)*p+1:N+itc*p]=
rev(dggen[itf-p:itf-1,itc]);
dggen[itf,itc]=dggen1'ben+ebt[itf-p,itc];
itf=itf+1;
endo;
it=2;
do while it<=T+1;
ggen[it,itc]=dggen[it-1,itc]+ggen[it-1,itc];
it=it+1;
endo;
itc=itc+1;
endo;
g1gen=ggen[1:T,.];
retp(dggen,g1gen);
endp;

proc(2)=resideltafun(dzm,z1m,pmax);
local rdzm,y,x,unos,x1,x2,itc,itp,be,en,em,
vari1,vari2,ivari1,ivari2,bes,xxi;
rdzm=rows(dzm);
y=zeros(tef*N,1);
x1=zeros(tef*N,N);
x2=zeros(tef*N,N*pmax);
itc=1;
do while itc<=N;
y[(itc-1)*tef+1:itc*tef]=dzm[pmax+1:rdzm,itc];
x1[(itc-1)*tef+1:itc*tef,itc]=z1m[pmax+1:rdzm,itc];
itp=1;
do while itp<=pmax;
x2[(itc-1)*tef+1:itc*tef,(itc-1)*pmax+itp]=
dzm[pmax-itp+1:rdzm-itp,itc];
itp=itp+1;
endo;
itc=itc+1;
endo;
x=x1~x2;
be=inv(x'x)*x'y;
en=y-x*be;
em=en[1:tef];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef+1:itc*tef];
itc=itc+1;
endo;
vari1=em'em/tef;
ivari1=inv(vari1);
vari2=vari1.*.eye(tef);
ivari2=ivari1.*.eye(tef);
xxi=inv(x'ivari2*x);
bes=xxi*x'ivari2*y;
en=y-x*bes;
em=en[1:tef];
itc=2;
do while itc<=N;
em=em~en[(itc-1)*tef+1:itc*tef];
itc=itc+1;
endo;
retp(bes,em);
endp;

proc(2)=gendgdelfun(ebt,ben);
local dggen,dggen1,ggen,g1gen,itf,itc,it;
dggen=zeros(T,N);
ggen=zeros(T+1,N);
ggen[1,.]=g[1,.];
dggen[1:p,.]=dg[1:p,.];
itc=1;
do while itc<=N;
itf=p+1;
do while itf<=T;
dggen1=zeros(N+N*p,1);
dggen1[itc]=ggen[itf-1,itc];
dggen1[N+(itc-1)*p+1:N+itc*p]=
rev(dggen[itf-p:itf-1,itc]);
dggen[itf,itc]=dggen1'ben+ebt[itf-p,itc];
itf=itf+1;
endo;
it=2;
do while it<=T+1;
ggen[it,itc]=dggen[it-1,itc]+ggen[it-1,itc];
it=it+1;
endo;
itc=itc+1;
endo;
g1gen=ggen[1:T,.];
retp(dggen,g1gen);
endp;

end;

Your Answer


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy