Saving bootstrapped series

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
mob7
Posts: 9
Joined: Tue May 03, 2011 9:40 am

Saving bootstrapped series

Unread post by mob7 »

Hi Tom,
I have a basic data management problem I can't fix, which builds on your reply to a previous post. I have a residual series for 500 individuals, with each series named res(m), m=1,2,...,500, and each res(m) series has different number of observations which are also in the dataset as series nobs(m)=(35,36,....,110). I am bootstrapping the residual series (ndraws=1000) for each m and need to keep the results of each draw for later, such that I will have a number of series which are identified by resboot(m)_(ndraw). However I can't seem to declare the right number of vectors to store the output of each draw for every m. The first block of code below is what I had thought as being the right way to do it - but it doesn't run at all. The second block runs, but obviously only stores the results for the 500th individual - any help would be appreciated.

comp ndraws=1000
comp indivs=500
do m=1,indivs
do i=1,ndraws
stats nobs(m)
comp nobs_shock = %mean
dec vect[series] resboot(m)_(ndraws)
set resboot(m)_(i) = res(m)(fix(%uniform(1,nobs_shock)))
end do i
end do m



comp ndraws=1000
comp indivs=500
do m=1,indivs
do i=1,ndraws
stats nobs(m)
comp nobs_shock = %mean
dec vect[series] resboot_(ndraws)
set resboot_(i) = res(m)(fix(%uniform(1,nobs_shock)))
end do i
end do m
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Saving bootstrapped series

Unread post by TomDoan »

The declare vect[series] instruction needs to be outside (before) the loop, not inside it.
mob7
Posts: 9
Joined: Tue May 03, 2011 9:40 am

Re: Saving bootstrapped series

Unread post by mob7 »

Thanks Tom. I am trying to avoid having to declare 500,000 series individually, which will then have the necessary series name to take the bootstrapped series. If I bring the declare command outside the loop it looks like below, and doesn't run (I tried shortening the series name to see if that was the problem but doesn't seem to be)

dec vect[series] resboot(indivs)_(ndraws)


The only way I know how to work it is to do the following, which is in essence declaring each series individually, and must be excessive. Is there a more efficient way?

dec vect[series] resboot(indivs)
set resboot1 = resboot(1)
set resboot2 = resboot(2)
.
.
.
.
set resboot500 = resboot(500)

dec vect[series] resboot1(ndraws)
dec vect[series] resboot2(ndraws)
.
.
.
.
dec vect[series] resboot500(ndraws)
set resboot(1)_(1) = resboot1(1)
set resboot(1)_(2) = resboot1(2)
.
.
.
.
set resboot(500)_(1000) = resboot500(1000)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Saving bootstrapped series

Unread post by TomDoan »

If it's two dimensional, do a RECT[SERIES] instead:

dec rect[series] resboot(indivs,ndraws)

with the corresponding changes to the subscripts in the program.
Post Reply