Looks like you have several coding issues here, and one theoretical issue.
First, the coding issues:
1) do iend = ibegin,iend
You don't want the same variable as the loop index variable and to specify the end of the loop. Try something like:
compute last = 2006:4
do iend = ibegin,last
instead.
2) You only need 10,000 draws for each period. So just make fdrawS a series with 10,000 elements, not a vector of 10,000 series.
3) Inside the "draw" loop, store the current forecast value (entry "iend+1" of the FCASTS series) into entry "draws" of the fdraws series. Here's one way to do that:
set fdrawS draw draw = fcasts(1)(iend+1)
4) It doesn't make sense to refer to entry "draw" on the SSTATS outside of the DO loop (since "draw" will just be equal to the last value from the loop). Also, you need to refer to a specific entry of LOGCANGDP, not not entry "t" (which would run from 1 through 10000). So, with that in mind and with fdrawS being a single series not an array of series, instead of:
sstats(mean) 1 10000 (fdrawS(draw)<=logcangdp(t))>>pit
I think you want:
sstats(mean) 1 10000 (fdrawS<=logcangdp(iend+1))>>pit
With the addition of the use of a variable for the number of draws, these changes give you this:
- Code: Select all
compute ndraws=10000
set fdrawS 1 ndraws = %na
compute last = ibegin+2
do iend = ibegin,last
estimate(noprint) iend-width+1 iend
clear fdrawS
do draw = 1,ndraws
forecast(model=canmodel,results=fcasts,from=iend+1,to=iend+1,noprint)
set fdrawS draw draw = fcasts(1)(iend+1)
end do draw
sstats(mean) 1 ndraws (fdrawS<=logcangdp(iend+1))>>pit
disp pit
end do iend
Which brings us to the theoretical problem: As written, you're just computing actual forecasts, producing the exact same forecasts for each draw, rather than doing any sort of simulation (such as the MCMC simulation Todd mentioned). So, this doesn't really produce any result. You would need to incorporate some simulation method into this for it to actual do anything. Not having read the papers, I assume they spell out a recommended approach?
Regards,
Tom Maycock