I am trying to bootsrap VAR residuals in an i.i.d. fashion.
Particularly, I should use this i.i.d. bootstrap of the residuals to generate a given number (say 10.000) of data sets, each of the same lenght as the actual data (after throwing out the first 100 data points to diminish the effect of starting values). For each of the 10.000 samples I have to recalculate the VAR parameters. Then subtract the mean of these estimates from the original parameters to obtain the small sample bias.
Folloing W.Enders' programming notes I have attempted to program what explained above for the univariate case - AR(1), i.e.:
Code: Select all
all 50
seed 2001
set x = %uniform(5,15)
set y = x**0.5 + %ran(1)
nonlin alpha beta
frml monte y = beta*x**alpha
com alpha = 0.48, beta = 0.98
nlls(frml=monte) y / e
com alpha_hat = %beta(1) , beta_hat = %beta(2)
set alpha_star 1 1000 = 0.
set beta_star 1 1000 = 0.
set discrep1 1 1000 = 0.
set discrep2 1 1000 = 0.
do i = 1,1000
set e_star = e(fix(%uniform(1,51)))
set y_star = beta_hat*x**alpha_hat + e_star
nonlin alpha beta
frml monte y_star = beta*x**alpha
com alpha = alpha_hat, beta = beta_hat
nlls(frml=monte,noprint) y_star
com alpha_star(i) = %beta(1) , beta_star(i) = %beta(2)
*Compute the bias for the 1000 obs.
com discrep1(i) = %beta(1) - alpha_hat
com discrep2(i) = %beta(2) - beta_hat
end do i
table / discrep1 discrep2
Any hint will be highly appreciated .
Many thanks
Corrado