seeking help: impulse responses with band by B-Q decomp
Posted: Sat Sep 29, 2007 10:54 am
According to Monteva2.prg in Estima website, a piece of code is written for impulse responses with band by Blanchard-Quah decomposition through Monte Carlo integration. Since there are four lines listed below which shall be added into the procedure, what makes me confused is where they should be inserted.
compute c=%varlagsums
compute s1=%mqform(%sigma,tr(inv(c)))
compute s2=%decomp(s1)
compute g=c*s2
impulse(model=irf_b,results=impblk,noprint,decomp=g) * nsteps *
Attached is a RATS procedure I wrote for BQ with band. I insert the above lines within "do draws" block. May anyone take a look to judge whether it's correct? If not, may you kindly modify it?
compute c=%varlagsums
compute s1=%mqform(%sigma,tr(inv(c)))
compute s2=%decomp(s1)
compute g=c*s2
impulse(model=irf_b,results=impblk,noprint,decomp=g) * nsteps *
Attached is a RATS procedure I wrote for BQ with band. I insert the above lines within "do draws" block. May anyone take a look to judge whether it's correct? If not, may you kindly modify it?
Code: Select all
*******************************
* impulse responses with band by Blanchard-Quah decomposition
* through Monte Carlo integration
*******************************
***** data input and transformation *****
calendar 1959:1
allocate 2002:1
open data gdp_rnd.xls
data(format=xls,organization=columns) / rgdp rrnd
set dlrgdp = (log(rgdp)-log(rgdp{1}))*100
set dlrrnd = (log(rrnd)-log(rrnd{1}))*100
***** VAR setup *****
compute neqn = 2
compute nvar = 2
compute nlags = 2
compute nstep = 12
compute ndraws = 2500
system(model=irf_bq)
variables dlrrnd dlrgdp
lags 1 to nlags
kfset xxx
deterministic constant
end(system)
estimate(outsigma=vmat,noftests,noprint)
***** graph impulse responses *****
declare rect sxx svt swish betaols betadraw
declare symm sigmad
compute sxx =%decomp(xxx)
compute svt =%decomp(inv(%nobs*vmat))
compute betaols=%modelgetcoeffs(irf_bq)
compute ncoef =%rows(sxx)
compute wishdof=%nobs-ncoef
declare rect ranc(ncoef,nvar)
declare vect[rect] responses(ndraws)
declare rect[series] impulses(nvar,nvar)
infobox(action=define,progress,lower=1,upper=ndraws) 'Monte Carlo Integration'
do draws = 1,ndraws
if %clock(draws,2)==1 {
compute sigmad =%ranwisharti(svt,wishdof)
compute swish =%decomp(sigmad)
compute ranc =%ran(1.0)
compute betau =sxx*ranc*tr(swish)
compute betadraw=betaols+betau
}
else
compute betadraw=betaols-betau
compute %modelsetcoeffs(irf_bq,betadraw)
compute c=%varlagsums
compute s1=%mqform(sigmad,tr(inv(c)))
compute s2=%decomp(s1)
compute g=c*s2
impulse(noprint,model=irf_bq,decomp=g,results=impulses) * nstep *
*
* Store the impulse responses
*
dim responses(draws)(nvar*nvar,nstep)
ewise responses(draws)(i,j)=impulses((i-1)/nvar+1,%clock(i,nvar))(j)
infobox(current=draws)
end do draws