Gibbs Minnesota VAR, structural residuals
Posted: Mon Apr 10, 2017 10:21 am
Dear Tom,
I am using the following code to estimate a GIBBS VAR with a Minnesota Prior and do impulse response analysis, where the identification comes from a Cholesky Decomposition:
What I want to do now is to calculate for every draw within the Gibbs sampler the identified structural residuals. How would I do that?
Best
jules
I am using the following code to estimate a GIBBS VAR with a Minnesota Prior and do impulse response analysis, where the identification comes from a Cholesky Decomposition:
Code: Select all
*** Data
open data haversample.rat
cal(q) 1959
data(format=rats) 1959:1 2006:4 ftb3 gdph ih cbhm
set loggdp = log(gdph)
set loginv = log(ih)
set logc = log(cbhm)
*** VAR Setup and Storage Matrices
compute lags=4 ;*Number of lags
compute nstep=40 ;*Number of response steps
compute nburn=500 ;*Number of burn-in draws
compute ndraws=2500 ;*Number of keeper draws
compute tight=.1
compute other=.5
system(model=varmodel)
variables loggdp loginv logc ftb3
lags 1 to lags
det constant
end(system)
estimate(ols,sigma) ;*initial set of estimations
impulse(noprint,model=varmodel,steps=nstep,results=impulses) ;*initial set of of impulse responses
display %cmom
compute nvar=%nvar
dec vect olssee(nvar)
ewise olssee(i)=sqrt(%sigma(i,i))
declare vect[rect] %%responses(ndraws)
declare rect[series] impulses(nvar,nvar)
*** Minnesota Prior using @BVARBuildPriorMN
source BVARBuildPriorMN.src
@BVARBuildPriorMN(model=varmodel,tight=tight,other=other) HBPRIORS HPRIORS
@BVARFinishPrior hbpriors hpriors bprior hprior
compute sigmad=%sigma
cmom(model=varmodel)
display hprior
display bprior
*** GIBBS Sampling Loop
infobox(action=define,progress,lower=-nburn,upper=ndraws) "Gibbs Sampler"
do draw=-nburn,ndraws
infobox(current=draw)
*
* Draw b given sigma
*
compute bdraw =%ranmvkroncmom(%cmom,inv(sigmad),hprior,bprior)
compute rssmat=%sigmacmom(%cmom,bdraw)
*
* Draw sigma given b
*
compute sigmad=%ranwisharti(%decomp(inv(rssmat)),%nobs)
if draw<=0
next
compute %modelsetcoeffs(varmodel,bdraw)
impulse(noprint,model=varmodel,results=impulses,steps=nstep)
*
* Store the impulse responses
*
dim %%responses(draw)(nvar*nvar,nstep)
local vector ix
ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
end do draw
infobox(action=remove)
*** Impulse Response
@mcgraphirf(model=varmodel,center=median,percentiles=||.10,.90||)
Best
jules