Code: Select all
set lsforesBoot = 0.
set fcst4_lsforesBoot = 0.
set fcst8_lsforesBoot = 0.
set fcst12_lsforesBoot = 0.
com start = 1975:01 + 133;
com end = 1997:06-12;
do cap_T = start, end
nonlin a0 a1 b0 b1 d0 d1
frml abranch = a0+a1*y{1}
frml bbranch = b0+b1*y{1}
frml lstarwt = 1.0/(1+exp(d0+d1*y{1}))
frml lstareq y = fstar=lstarwt,abranch*(1-fstar)+ bbranch*fstar
stats(noprint) y
compute ymean=%mean
linreg(noprint,smpl=(y{1}<ymean)) y * cap_T
# constant y{1}
compute a0=%beta(1),a1=%beta(2)
linreg(noprint,smpl=(y{1}>ymean)) y * cap_T
# constant y{1}
compute b0=%beta(1),b1=%beta(2)
compute d0=50.0*ymean,d1=-50.0
nlls(noprint,frml=lstareq,trace,pmethod=simplex,method=evaluate,piters=20,cvcrit=0.01,iters=40) y * cap_T
set resids = %resids ;
group lstarmodel lstareq>>lsforesBoot
set meanBoot cap_T+1 cap_T+12 = 0.0
compute ndraws = 2500
do draws = 1,ndraws
boot entries * cap_T
set path = resids(entries)
forecast(model=lstarmodel,paths,results=bootsim,steps=12,from=cap_T+1)
# path
set meanBoot cap_T+1 cap_T+12 = meanBoot + bootsim(1)
end do draws
set meanBoot cap_T+1 cap_T+12 = meanBoot/ndraws
compute fcst4_lsforesBoot(cap_T+4) = meanBoot(cap_T+4)
compute fcst8_lsforesBoot(cap_T+8) = meanBoot(cap_T+8)
compute fcst12_lsforesBoot(cap_T+12) = meanBoot(cap_T+12)
end do cap_T
Code: Select all
set valid_draw = 0.0
.....
set meanBoot cap_T+1 cap_T+12 = %if(%valid(meanBoot), bootsim(1) + meanBoot, 0)
SET valid_draw = %if(%valid(meanBoot), 1, 0) + valid_draw
*or
*if %valid(meanBoot(t)) == 1; set meanBoot cap_T+1 cap_T+12 = bootsim(1) + meanBoot
*and then write
set meanBoot4 = meanBoot(cap_T+4)/valid_draw(cap_T+4)
set meanBoot8 = meanBoot(cap_T+8)/valid_draw(cap_T+8)
set meanBoot12 = meanBoot(cap_T+12)/valid_draw(cap_T+12)
Anybody have any suggestions of what am I doing wrong? The reason I am puzzled is that when I Monte Carlo simulate the forecasts everything is working well.
Thanks in advance,
R.P.