Near-SVAR with Monte Carlo integration

Questions and discussions on Vector Autoregressions
CRMS
Posts: 7
Joined: Fri Mar 23, 2012 9:52 am

Near-SVAR with Monte Carlo integration

Unread post by CRMS »

Hello,

I am trying to set up a 7 variable near-VAR, where 3 (foreign) variables are assumed to stay unaffected by the other 4 (domestic) variables. Using the MonteSUR program, I am able to estimate the resulting impulse responses with a Cholesky factorization; however, I would prefer to apply a more adequate structural factorization, as some of my responses seem to lack in economic sense.

I have therefore tried to combine the MonteSUR and MonteSVAR programs into a single program with Monte Carlo integration. The draw for the factor matrix swish has not been a problem; in fact, the program works perfectly well as a regular SVAR without any exogeneities. However, the draw for beta has given me a puzzle. In MonteSVAR, it is based on the covariance matrix of the estimates sxx, but this is and cannot be given by the SUR instruction used in MonteSUR (the RATS variable %xx given by SUR has far too many rows, given that each regressor from each equation is treated as unrelated). I have therefore tried to make the beta draw in the same way as in MonteSUR, that is by estimating the SUR within the Monte Carlo loop, using the structural factor matrix swish as my input matrix.

In a small 3 variable test model, this little trick seemed to work. However, once I started working with the full system, I got the "## REG12. SIGMA Is Singular/Not PSD At Row 5. Too Many Equations for Data Set Size?" error. My data set is indeed not as big as I wished it was, but it has so far been sufficient for the estimation of either a 'normal' near-VAR or a 'normal' SVAR. I assume that the problem lies with my program code rather than with my data set size.

The following is my Monte Carlo loop. Any comments or suggestions how to solve my problem are very much welcome!

Code: Select all

compute sumwt=0.0,sumwt2=0.0
do draws = 1,ndraws
*
   if %clock(draws,2)==1 {
*
      compute au      =%rant(nu)
      compute %parmspoke(amatrix,axbase+saxx*au)
      compute a       =afrml(1)
      compute dhat    =a*sigmahat*tr(a)
      compute ddiag   =%xdiag(dhat)
      cvmodel(parmset=amatrix,dfc=ncoef,pdf=delta,dmatrix=marginalized,method=evaluate) sigmahat afrml
      compute pdensity=%funcval
      compute idensity=-((nu+nfree)/2.0)*log(nu+%dot(au,au))
*
      compute weight  =exp(pdensity-scladjust-idensity-((nu+nfree)/2.0)*log(nu))
*
      ewise d(i)      =(%nobs/2.0)*ddiag(i)/%rangamma(.5*(%nobs-ncoef)+delta+1)
*
      compute swish   =inv(a)*%diag(%sqrt(d))
*
      sur(noprint,nosigma,model=nearsvar,cv=swish)
      compute ransur =%ran(1.0)
      compute betau =%decomp(%xx)*ransur
      compute surdraw =%beta+betau
   }
*
   else {
*
      compute surdraw =%beta-betau
   }
   compute %matpoke(fullcoeff,slots,surdraw)
   compute %modelsetcoeffs(nearsvar,fullcoeff)
   impulse(noprint,model=nearsvar,factor=swish,results=impulses,steps=nstep) nvar
*
   compute sumwt   =sumwt+weight
   compute sumwt2  =sumwt2+weight**2
   dim responses(draws)(nvar*nvar,nstep)
   compute weights(draws)=weight
   ewise responses(draws)(i,j)=impulses((i-1)/nvar+1,%clock(i,nvar))(j)
   infobox(current=draws)
end do draws
infobox(action=remove)
*
Best regards
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-SVAR with Monte Carlo integration

Unread post by TomDoan »

You can't combine those the way they are written because MONTESVAR uses importance sampling for the contemporaneous model and does direct draws from the posterior for the lag coefficients. That works for a full VAR because the posterior distribution of sigma doesn't depend upon beta. For a near-VAR, that's not the case, which is why MONTESUR.RPF has to recompute the sample covariance matrix at the draw for beta.

To combine the two, you would need to use Metropolis-within-Gibbs for the structural VAR part. Importance sampling and Metropolis-within-Gibbs are quite similar---the first keeps all draws and weights them, while the second does the weighting by staying put for draws with a high desirability. The relationship between these (as well as Bayesian inference for both SUR and VAR models) is discussed in detail in the Bayesian Econometrics e-course. The following is a page from the section on SVAR models:
var_extract.pdf
Importance sampling vs M-H
(29.65 KiB) Downloaded 819 times
CRMS
Posts: 7
Joined: Fri Mar 23, 2012 9:52 am

Re: Near-SVAR with Monte Carlo integration

Unread post by CRMS »

Hello,

I have acquired and studied both the VAR and the Bayesian Econometrics course material. However, I am still puzzled by the question of how to calculate the impulse responses for an SVAR using Metropolis-within-Gibbs (or Metropolis-Hastings, as it is usually called in the course material).

From what I understand, the antithetic acceleration technique used by the programs I previously employed for my impulse responses - MONTESVAR or the MCVARDoDraws procedure - cannot be used for MCMC techniques because this would interrupt the Markov Chain upon which the Gibbs sampler is based. On the other hand, the examples of Metropolis-within-Gibbs given in the Bayesian course material (6.4 and 6.5) don't contain the IMPULSE instruction normally used for impulse responses. Instead, they show me how to estimate the theta's (series tgibbs) and lambda's (lgibbs) for any given SVAR.

I am now unsure how to proceed. Can I retrieve the impulse responses from the information stored in tgibbs or lgibbs? Or do I have to implement the IMPULSE instruction within the Gibbs sampler? My idea for that case would be running the IMPULSE instruction for each draw that is accepted and storing the results in a vector called RESPONSES, analogous to the case of importance sampling - but I am not sure whether that makes any sense here. Furthermore, I am not sure where to find the factorization of the covariance matrix needed for IMPULSES. Could I use the CVMODEL instruction to get it, even if my model is overidentified?

I hope my questions don't sound too confused; MCMC techniques are still very new to me.

Best regards
CRMS
Posts: 7
Joined: Fri Mar 23, 2012 9:52 am

Re: Near-SVAR with Monte Carlo integration

Unread post by CRMS »

Maybe my question was not clear-cut enough... I would like to know how to proceed in order to obtain impulse responses from a structural VAR estimated with Random walk MH or Independence chain MH, in the vein of examples 6.4 and 6.5 of the RATS Handbook for Bayesian Econometrics. I know I have to use the IMPULSE instruction, but I don't know which factor is needed.

Best regards
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Near-SVAR with Monte Carlo integration

Unread post by TomDoan »

I posted an example at

http://www.estima.com/forum/viewtopic.php?f=8&t=1582

The M-H estimation for a structural VAR can require some experimentation. This example uses random walk Metropolis, which probably will work reasonably well in most situations.


Last bumped by TomDoan on Mon Jun 22, 2015 2:13 pm.
Post Reply