Hello. I could help. How I can generate shocks of 1% in the exogenous variables in a SVAR program?
Thanks for any help! (e-mail address: torresgc@bccr.fi.cr)
torresgc wrote:Hello. I could help. How I can generate shocks of 1% in the exogenous variables in a SVAR program?
Thanks for any help! (e-mail address: torresgc@bccr.fi.cr)
*
* Monte Carlo integration with shock to "exogenous" variable
*
compute lags=4 ;*Number of lags
compute nstep=16 ;*Number of response steps
compute ndraws=10000 ;*Number of keeper draws
*
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)
*
* T-Bill rate is treated as exogenous
*
system(model=varmodel)
variables loggdp loginv logc
lags 1 to lags
det constant ftb3{1 to 4}
end(system)
*
* Define placeholder equation to allow shock to T-bills.
*
equation(empty) rateeq ftb3
*
******************************************************************
estimate
compute nshocks=1
compute nvar =%nvar
compute fxx =%decomp(%xx)
compute fwish =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(varmodel)
*
declare vect[rect] %%responses(ndraws)
declare rect[series] impulses(nvar,nvar)
infobox(action=define,progress,lower=1,upper=ndraws) "Monte Carlo Integration"
do draw=1,ndraws
*
* On the odd values for <<draw>>, a draw is made from the inverse Wishart
* distribution for the covariance matrix. This assumes use of the
* Jeffrey's prior |S|^-(n+1)/2 where n is the number of equations in
* the VAR. The posterior for S with that prior is inverse Wishart with
* T-p d.f. (p = number of explanatory variables per equation) and
* covariance matrix inv(T(S-hat)).
*
* Given the draw for S, a draw is made for the coefficients by adding
* the mean from the least squares estimate to a draw from a
* multivariate Normal with (factor of) covariance matrix as the
* Kroneker product of the factor of the draw for S and a factor of
* the X'X^-1 from OLS.
*
* On even draws, the S is kept at the previous value, and the
* coefficient draw is reflected through the mean.
*
if %clock(draw,2)==1 {
compute sigmad =%ranwisharti(fwish,wishdof)
compute fsigma =%decomp(sigmad)
compute betau =%ranmvkron(fsigma,fxx)
compute betadraw=betaols+betau
}
else
compute betadraw=betaols-betau
*
* Push the draw for the coefficient back into the model.
*
compute %modelsetcoeffs(varmodel,betadraw)
*
* Shock the combination of the VAR + the placeholder equation with a
* unit shock to the placeholder.
*
impulse(noprint,model=varmodel+rateeq,shocks=%unitv(%nvar+1,%nvar+1),$
result=impulses,steps=nstep)
*
* Save the impulse responses
*
dim %%responses(draw)(nvar*nshocks,nstep)
ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
infobox(current=draw)
end do draw
infobox(action=remove)
*
@mcgraphirf(model=varmodel,shocklabels=||"To Interest Rate"||)
TomDoan wrote:That's what this does. The only shock analyzed is to the variable treated as exogenous.
TomDoan wrote:That's what this does. The only shock analyzed is to the variable treated as exogenous.
TomDoan wrote:Use the ACCUMULATE instruction. See, for instance, what the BQDODRAWS procedure does.
wfirew wrote:I am estimating a vector error correction model (vecm) and a shock to the exogenous variable as described above does not work. Any suggestion?
Best,
*
* Monte Carlo integration with shock to "exogenous" variable
*
compute lags=4 ;*Number of lags
compute nstep=16 ;*Number of response steps
*
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)
*
* T-Bill rate is treated as exogenous
*
setset dftb3 = ftb3 - ftb3{1}
equation(coeffs=||1.0,0.3,0.3,0.3||) ect1
# loggdp loginv logc ftb3
system(model=vecmmodel)
variables loggdp loginv logc
lags 1 to lags
ect ect1
det constant dftb3{0 to 3}
end(system)
*
* Define placeholder equation to allow shock to T-bills.
*
equation(empty) rateeq ftb3
*
******************************************************************
estimate
impulse(noprint,model=vecmmodel+rateeq,shocks=%unitv(%nvar+1,%nvar+1),$
result=impulses,steps=nstep)
Return to VARs (Vector Autoregression Models)
Users browsing this forum: No registered users and 1 guest