/* ** Bootstrap OLS */ @ Data generation under Weak Ideal Conditions @ /* ** The regressors are lagged dependent variables. ** That is, regressors are stochastic. ** The errors are different across different data sets. ** Errors are non-normal: Chi-square(2)-2 */ new; @ open output file @ output file = bootols_dynamic.out reset ; @ Model: y(t) = beta(1) + beta(2)*y(t-1) + e @ seed = 1; beta2 = 0.5; beta1 = 0.5; tt = 10; @ # of observations @ kk = 2; @ # of betas @ iter = 5000; @ # of sets of different data @ nboot = 1000; @ Generating y @ y = 0 ; j = 1; do while j <= tt; y = y|(beta1+beta2*y[j,.]+2*(rndns(1,1,seed)^2+rndns(1,1,seed)^2-2) ); j = j + 1; endo; @ OLS using yy and xx @ yy = y[2:tt+1,.]; xx = ones(tt,1)~y[1:tt,.]; olsb = invpd(xx'xx)*(xx'yy); olse = yy - xx*olsb ; s2 = (olse'olse)/(tt-kk); v = s2*invpd(xx'xx); se = sqrt(diag(v)); @ testing H_o: beta2 = true beta 2 @ asympw = ( (olsb[2]-beta2)/se[2] )^2 ; asympp = cdfchic(asympw,1); asympw1 = ( (olsb[2]-1)/se[2] )^2 ; asympp1 = cdfchic(asympw1,1); "Asymptotic Wald test result for H_o: beta2 = true beta2 (" beta2 ")"; " Wald Stat, p-val:" asympw asympp ; ""; "Asymptotic Wald test result for H_o: beta2 = 1"; " Wald Stat, p-val:" asympw1 asympp1 ; ""; @ Boot strap tests @ bootw = zeros(nboot,1) ; i = 1 ; do while i <= nboot ; cboot = ceil( tt*rndus(tt,1,seed) ) ; @ choosing bootstrap data points @ boote = olse[cboot,.] ; boy = y[1,.] ; j = 1; do while j <= tt; boy = boy|(olsb[1]+olsb[2]*boy[j,.]+boote[j,.]) ; j = j + 1; endo; @ Bootstrap OLS using yy and xx @ byy = boy[2:tt+1,.]; bxx = ones(tt,1)~boy[1:tt,.]; bootb = invpd(bxx'bxx)*(bxx'byy); boote = byy - bxx*bootb ; bs2 = (boote'boote)/(tt-kk); bv = bs2*invpd(bxx'bxx); bse = sqrt(diag(bv)); bootw[i] = ( (bootb[2]-olsb[2])/bse[2] )^2 ; i = i + 1 ; endo ; @ BOOTSTRAP CRITICAL VALUES @ bootwt = sortc(bootw,1) ; tc = nboot ; bootc = bootwt[ceil(tc*0.99)]|bootwt[ceil(tc*0.95)]|bootwt[ceil(tc*0.9)]; "" ; "BOOTSTRAP WALD TEST FOR H_o: beta2 = true (" beta2 ")" ; ""; " STATISTICS C-VAL-1% C-VAL-5% C-VAL-10% "; asympw bootc' ; "" ; "BOOTSTRAP WALD TEST FOR H_o: beta2 = 1"; ""; " STATISTICS C-VAL-1% C-VAL-5% C-VAL-10% "; asympw1 bootc' ; output off;