Discrepancy between Simple IRFs and Monte Carlo IRFs
Re: Discrepancy between Simple IRFs and Monte Carlo IRFs
You'll have to post your whole program. (You can do an attachment). You're not showing the procedure call that does the Monte Carlo, so I can't tell why that would fail.
Re: Discrepancy between Simple IRFs and Monte Carlo IRFs
Sorry, here it is
Code: Select all
compute nvar = 3
compute nlags = 1
compute nsteps = 100
compute ndraws = 500
*
system(model=threevar)
var d2lrgdp dprivs dgovs
lags 1 to nlags
det
end(system)
estimate(noprint,resids=resids)
compute vsigma=%sigma
*
@Varlagselect(lags=8,crit=aic)
# d2lrgdp dprivs dgovs
@Varlagselect(lags=8,crit=hq)
# d2lrgdp dprivs dgovs
@Varlagselect(lags=8,crit=sbc)
# d2lrgdp dprivs dgovs
*
dec rect lr(3,3) sr(3,3)
input lr
. 0 0
. . .
. . .
input sr
. . .
. . .
. 0 .
dec vect[strings] shocklabels varlabels
compute shocklabels=||"Output","Private Savings","Public Savings"||
compute varlabels=||"Real GDP","Private Savings Rate","Public Savings Rate"||
*
@ShortAndLong(lr=lr,sr=sr,masum=inv(%varlagsums)) %sigma f
compute fd=%xdiag(f)
ewise f(i,j)=f(i,j)/fd(j)
*
****Point Estimate*****
*
@varirf(model=threevar,steps=nsteps,factor=f,page=byshock,accum=||1,2,3||,$
shocks=shocklabels,varlabels=varlabels)
*
****Monte Carlo Simulation****
*
*
procedure SRLRDoDraws
*
option model model threevar
option integer draws 500
option integer steps 100
option vect[int] accum ||1,2,3||
option rect lr
option rect sr
*
local integer nvar
local rect fxx fwish fsigmad factor
local integer wishdof
local rect betaols betau betadraw
local vect ix
local symm sigmad
local integer i j draw
*
if .not.%defined(model) {
disp "###SRLRDoDraws(MODEL=model name,other options)"
return
}
compute nvar=%modelsize(model)
*
* Standard setup for drawing from an OLS VAR
*
compute fxx =%decomp(%xx)
compute fwish =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(model)
*
local rect[series] impulses(nvar,nvar)
*
* These are global variables
*
declare vect[rect] %%responses(draws)
*
infobox(action=define,progress,lower=1,upper=draws) "Monte Carlo Integration"
do draw=1,draws
if %clock(draw,2)==1 {
compute sigmad =%ranwisharti(fwish,wishdof)
compute fsigmad =%decomp(sigmad)
compute betau =%ranmvkron(fsigmad,fxx)
compute betadraw=betaols+betau
}
else
compute betadraw=betaols-betau
compute %modelsetcoeffs(model,betadraw)
*
* Compute the short-and-long-run factor using the recalculated lag
* sums of the model.
*
@ShortAndLong(lr=lr,sr=sr,masum=inv(%modellagsums(model))) sigmad factor
impulse(noprint,model=model,factor=factor,results=impulses,steps=steps)
*
* Accumulate the responses as requested
*
do i=1,%rows(accum)
do j=1,nvar
acc impulses(accum(i),j) 1 steps
end do j
end do i
*
* Store the impulse responses
*
dim %%responses(draw)(nvar*nvar,steps)
ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
infobox(current=draw)
end do draw
infobox(action=remove)
*
* Restore the original coefficients
*
compute %modelsetcoeffs(model,betaols)
*
end SRLRDoDraws
*
@SRLRDoDraws(accum=||1,2,3||,steps=nsteps,model=threevar,lr=lr,sr=sr)
*@MCGraphIRF(model=threevar,shocklabels=shocklabels,varlabels=varlabels,page=byshock)
@MCProcessIRF(model=threevar,percentiles=||.16,.84||,center=median,lower=lower,upper=upper,irf=irf)
copy(format=xls,org=columns) / irf lower upper
*
Re: Discrepancy between Simple IRFs and Monte Carlo IRFs
When I said, take the SRLRDoDraws out of the Bjornland-Leitemo and not change it, I meant exactly. Do not change the values at top---that's what the option fields when you do @SRLRDODRAWS take care of. (Your call seems to be correct). Take what you have now and replace it with what I have below.
Code: Select all
procedure SRLRDoDraws
*
option model model
option integer draws 10000
option integer steps 40
option vect[int] accum
option rect lr
option rect sr
*
local integer nvar
local rect fxx fwish fsigmad factor
local integer wishdof
local rect betaols betau betadraw
local vect ix
local symm sigmad
local integer i j draw
*
if .not.%defined(model) {
disp "###SRLRDoDraws(MODEL=model name,other options)"
return
}
compute nvar=%modelsize(model)
*
* Standard setup for drawing from an OLS VAR
*
compute fxx =%decomp(%xx)
compute fwish =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(model)
*
local rect[series] impulses(nvar,nvar)
*
* These are global variables
*
declare vect[rect] %%responses(draws)
*
infobox(action=define,progress,lower=1,upper=draws) "Monte Carlo Integration"
do draw=1,draws
if %clock(draw,2)==1 {
compute sigmad =%ranwisharti(fwish,wishdof)
compute fsigmad =%decomp(sigmad)
compute betau =%ranmvkron(fsigmad,fxx)
compute betadraw=betaols+betau
}
else
compute betadraw=betaols-betau
compute %modelsetcoeffs(model,betadraw)
*
* Compute the short-and-long-run factor using the recalculated lag
* sums of the model.
*
@ShortAndLong(lr=lr,sr=sr,masum=inv(%modellagsums(model))) sigmad factor
*
* The rescaling done in the next two lines is specific to this paper
*
compute fd=%xdiag(factor)
ewise factor(i,j)=factor(i,j)/fd(j)
*
impulse(noprint,model=model,factor=factor,results=impulses,steps=steps)
*
* Accumulate the responses as requested
*
if %defined(accum) {
do i=1,%rows(accum)
do j=1,nvar
acc impulses(accum(i),j) 1 steps
end do j
end do i
}
*
* Store the impulse responses
*
dim %%responses(draw)(nvar*nvar,steps)
ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
infobox(current=draw)
end do draw
infobox(action=remove)
*
* Restore the original coefficients
*
compute %modelsetcoeffs(model,betaols)
*
end SRLRDoDrawsRe: Discrepancy between Simple IRFs and Monte Carlo IRFs
Is it possible (and reasonable) to standardise a shock to be a unit shock. I've read a couple of other threads on this and the Handbook for Vector Autoregressions but can't find any examples relevant to the Blanchard-Quah factorisation and when I implement "factor=%impulse(%nvar)" it ignores the long run restriction which is not what I want.
Is there a procedure for this like the Mcvardodrawsunit.src?
Is there a procedure for this like the Mcvardodrawsunit.src?
Re: Discrepancy between Simple IRFs and Monte Carlo IRFs
What does "unit shock" mean in this situation? You're doing a structural model where all shocks probably hit all variables contemporaneously.
Because this is a linear model, you can always rescale the columns of the factor to achieve different size shocks. You just have to decide what impacts you want. The @MCVARDODRAWSUNIT procedure is for simple unit shocks to each variable.
Because this is a linear model, you can always rescale the columns of the factor to achieve different size shocks. You just have to decide what impacts you want. The @MCVARDODRAWSUNIT procedure is for simple unit shocks to each variable.