Page 1 of 1
Empirical distribution of Beta
Posted: Wed May 26, 2010 4:21 am
by comac
Hi everybody,

. I am not expert with bootstrapping and this is my very first simulation.
I have estimated a VAR to test for UIP, i.e. Et st+l - st = beta(it,l - it,l*) + vt. The VAR is (Delta st, it,l, it,l*).
I want to derive the empirical distribution of the VAR implied slope coefficient beta by means of bootstrapped residuals. Could anybody help (or, is there any example)?
Thanks in advance
Re: Empirical distribution of Beta
Posted: Wed May 26, 2010 11:41 am
by TomDoan
There's an example of bootstrapping with a VAR on the forum at:
http://www.estima.com/forum/viewtopic.php?f=4&t=642
A simpler example is this, from Lutkepohl's
New Introduction to Multiple Time Series Analysis. After the ESTIMATE inside the loop, you need to do your calculation and save the results as described in chapter 13 of the
User's Guide.
Data file:
- e1.dat
- (2.64 KiB) Downloaded 973 times
Re: Empirical distribution of Beta
Posted: Wed May 26, 2010 12:05 pm
by comac
Thanks a lot Tom.
Re: Empirical distribution of Beta
Posted: Thu May 27, 2010 4:10 am
by comac
Tom, I guess I am pretty close but I would need a final hint from you.
In the codes below I've run the program making all the computations. I would expect however that when I ask RATS to compute 'betauip', it would do it for each draw (so that I could have a distribution). Unfortunately the program does not expect 'comp betauip(draw)' but simply 'comp betauip'. So in the end I finish up with just one value and not a series.
Could you please have a look at that? Many thanks
Code: Select all
SYSTEM(model=varmodel)
VARIABLES DE BUK BUS UKINFL USINFL
LAGS 1 TO 2
DET CONSTANT
END(SYSTEM)
ESTIMATE(sigma,coeffs=coeffs,RESIDUALS=RESIDS) 1976:03 2008:6
SOURCE 'C:\Program Files\WINRATS 7\VARBOOTSETUP.src'
@VARBootSetup(model=varmodel) bootvar
*
compute rstart=%regstart()
compute rend =%regend()
*
compute bootdraws=1000
compute nvar =5
compute nsteps=8
declare vect[rect] %%responses
dim %%responses(bootdraws)
declare rect[series] impulses(nvar,nvar)
declare vect ix
*
infobox(action=define,progress,lower=1,upper=bootdraws) $
"Bootstrap Simulations"
do draw=1,bootdraws
@VARBootDraw(model=varmodel,resids=resids) rstart rstart rstart rend
*
* Estimate the model with resampled data
*
estimate(noprint,noftests) rstart rend
compute betauip = SOMECODE
infobox(current=draw)
end do draw
infobox(action=remove)
dis 'UIP Implied Beta Coeff. ' betauip
Re: Empirical distribution of Beta
Posted: Thu May 27, 2010 8:33 am
by TomDoan
comac wrote:Tom, I guess I am pretty close but I would need a final hint from you.
In the codes below I've run the program making all the computations. I would expect however that when I ask RATS to compute 'betauip', it would do it for each draw (so that I could have a distribution). Unfortunately the program does not expect 'comp betauip(draw)' but simply 'comp betauip'. So in the end I finish up with just one value and not a series.
Could you please have a look at that? Many thanks
First, a couple of minor points:
compute V_inn = (VCV~%zeros(5,5))~~%zeros(5,10)
could be more conveniently written
compute V_inn = (VCV~\%zeros(5,5))
since that would automatically give you the zeros in the non-diagonal part.
dec vector eds(10)
comp eds = ||1|0|0|0|0|0|0|0|0|0||
dec vector ei(10)
comp ei = ||0|1|0|0|0|0|0|0|0|0||
dec vector eistar(10)
comp eistar = ||0|0|1|0|0|0|0|0|0|0||
dec vector edp(10)
comp edp = ||0|0|0|1|0|0|0|0|0|0||
dec vector edpstar(10)
comp edpstar = ||0|0|0|0|1|0|0|0|0|0||
Use the %UNITV function:
comp eds = %unitv(10,1)
comp ei = %unitv(10,2)
...
The following are specific to the impulse responses. You don't need them:
declare vect[rect] %%responses
dim %%responses(bootdraws)
declare rect[series] impulses(nvar,nvar)
declare vect ix
What you
do need is
dec vect[vect] betauip(bootdraws)
(or just vect if betauip is a scalar)
and then
compute betauip
(draw) = tr(eds)*C*PHI*(ei-eistar)/120*inv(tr(ei-eistar)*PHI*(ei-eistar))
inside the loop.
Re: Empirical distribution of Beta
Posted: Thu May 27, 2010 9:03 am
by comac
Tom, now works better as I am able to obtain a string for 'betauip'. However I did not consider that the coefficient matrix A and the var-cov of innovations have to change at each replication. In fact now I have a matrix betauip(draw) where all elements are equal.
Thank you for your patience.

Re: Empirical distribution of Beta
Posted: Thu May 27, 2010 10:28 am
by TomDoan
Is there any reason to keep all those other calculations. Don't you just need the beta?
Yes. For any of those things that you have, there's a VECT on the outside, since you have one element per draw, then the type of object that you're saving on the inside. So if you need to save the A's, you need VECT[RECT] since A is a RECT. But if part of the calculation is "disposable", don't go to the trouble of saving it.
Re: Empirical distribution of Beta
Posted: Thu May 27, 2010 12:49 pm
by comac
Tom I sure just need the betas! But as it was before I couldn't have the distribution of beta. I simply had a string of all betas having the same values (which made me suspect there was something wrong).
I guess (and I would need your opinion on this purpose!) that the problem here is that EACH beta has to be computed as 'betauip' predicts. But for each bootstrap replication A needs being reestimated and so the other parameters from the VAR.
I don't know if I am comlicating things, but where am I wrong? Do you have any idea why RATS crashes?
Re: Empirical distribution of Beta
Posted: Thu May 27, 2010 1:14 pm
by TomDoan
The ESTIMATE inside the loop is computing BOOTVAR, not VARMODEL. (VARMODEL needs to stay around since it's used as the basis for generating the bootstrapped data). You need the following inside the loop, since these are the calculations which depend upon the bootstrapped data:
compute A = %modelcompanion(bootvar)
compute VCV = %modelgetvcv(bootvar)
compute V_inn = (VCV~\%zeros(5,5))
comp uncvar = inv(%identity(100) - %kroneker(A,tr(A)))*%vec(V_inn)
comp PHI = %vectorect(uncvar,10)
comp C = A*(%identity(10)-A^120)*inv(%identity(10)-A)
All those are disposable, so once you have the beta, you won't need them and can overwrite them next time through.
Re: Empirical distribution of Beta
Posted: Fri May 28, 2010 6:36 am
by comac
Tom thanks so much. It works perfectly!!