function bundle GVS_test(series y, int Bound[1::1], int CV[1:3:2], bool B[0]) #-------------------------------------------------------------------------- # Gómez and Ventosa-Santaulària broken-drift test under # the assumption that there is a unit-root #-------------------------------------------------------------------------- # Input: # y: time series to be studied # Bound: # of obs. ommitted at the beginning and the end of the sample # Minimum = default = 1 # CV: Choose the level of the test (1-3): # (1) 1%; (2) 5%; (3) 10% # Default: (1) 5% # B: Decide whether to look for a break or not: # 1 -> looks for a single break # 0 -> Does not look for a break # Default: 0 #-------------------------------------------------------------------------- # Output: # Results.stat : the statistic test value [R^2] # Results.Decision: whether the null is rejected or not # Results.beta : the estimate of the deterministic trend # Results.gamma : the estimate of the (zero if no evidence of it) # Results.Break : Indicates whether there is a break or not # Results.date : Indicates the # of the obs. where the break lies # Results.tgamma : The t-ratio of the break. Provided (in absolute value) # only if B=1 and there is evidence of a drift # (otherwise it does not make sense) #-------------------------------------------------------------------------- # Requires J.P. LeSage toolbox! available for free at: # http://www.spatial-econometrics.com/ #-------------------------------------------------------------------------- # written by: # Daniel Ventosa-Santaulària Dept of Economics and Finance # Universidad de Guanajuato # Mexico # daniel@ventosa-santaularia.com #-------------------------------------------------------------------------- ### excluding obs. at the beginning and at the end smpl y --contiguous T=$nobs genr time matrix Trend={time} Tbound=T-2*Bound #-------------------------------------------------------------------------- ### Test statistic without breaks ols y 0 time --quiet scalar R2_nb=$rsq scalar beta_nb=$coeff[2] if CV==1 CVu=0.94 elif CV==2 CVu=0.89 else CVu=0.84 endif if R2_nb>CVu Des_1=1 else Des_1=0 endif #-------------------------------------------------------------------------- ### Test statistic with a break matrix t_gamma0 = zeros(T-Bound, 1) matrix R2_wb0 = zeros(T-Bound, 1) matrix Param_tb0 = zeros(T-Bound, 2) loop i=Bound+1..T-Bound --quiet scalar k=T-Trend[i] series DT= zeros(Trend[i],1) | Trend[1:k] ols y 0 time DT --quiet t_gamma0[i]=$coeff[3]/$stderr[3] R2_wb0[i]=$rsq Param_tb0[i,]=$coeff[2:3]' endloop R2_wb=maxc(R2_wb0) LT=imaxc(R2_wb0) Break=Trend[LT] Param_tb=Param_tb0[LT,] t_gamma=abs(t_gamma0[LT]/T^(0.5)) Le=Break/T matrix dif=zeros(6,1) loop j=1..6 --quiet # Breaks(j,1)=j*0.15 dif[j,1]=abs(Le-j*0.15) endloop Dfm = minc(dif) row = iminc(dif) Tvc = {0.88,0.91,0.96 ; 0.89,0.93,0.96 ; \ 0.90,0.93,0.96 ; 0.90,0.93,0.96 ; \ 0.88,0.92,0.96 ; 0.87,0.91,0.96} if CV==1 Colu=3 elif CV==2 Colu=2 elif CV==3 Colu=1 endif CV_adec=Tvc[row,Colu] if R2_wb>CV_adec Des_2=1 else Des_2=0 endif Tvd = {0.84,1.00,1.33 ; 1.22,1.48,2.02 ; \ 1.41,1.71,2.39 ; 1.37,1.66,2.32 ; \ 1.11,1.33,1.83 ; 0.67,0.79,1.04} CV_tg=Tvd[row,Colu] if t_gammaCV_tg if Des_2==1 Break_des=1 else Break_des=0 endif endif scalar stat=NA scalar tgamma=NA string Breakstr="N/A" if B==1 if Break_des==1 stat=R2_wb if Des_2==1 Decision="No-drift hypothesis Rejected" Breakstr="There is evidence of a break" tgamma=t_gamma else Decision="No-drift hypothesis Accepted" endif elif Break_des==0 stat=R2_wb if Des_2==1 Decision="No-drift hypothesis Rejected" Breakstr="There is no evidence of a break" tgamma=t_gamma else Decision="No-drift hypothesis Accepted" endif endif beta=Param_tb[1] gamma=Param_tb[2] date=Break else if Des_1==1 Decision="No-drift hypothesis Rejected" else Decision="No-drift hypothesis Accepted" endif beta=beta_nb gamma=0 date=0 endif bundle b b["stat"] = stat b["Decision"] = Decision b["beta"] = beta b["gamma"] = gamma b["Break"] = Breakstr b["date"] = date b["tgamma"] = tgamma return b end function