3. Los contenidos de ElEstetoscopio.com
3.4. Ideas para el futuro
At the beginning of iterationn we have: spn 1; ssn 1; von 1; ST
n 1; sp;T n 1; vo;T n 1; H sp n 1; Hnm 1;and Hvo n 1:
Step 1: Sampling the Markov-switching states sp;Tn and vo;Tn
Conditional on the DSGE parameters and on ST
n 1, we have a Markov-switching VAR with known hyperparameters:
St = T ( spt )St 1+R( spt ) t (15)
t N(0; Q( vot )); Q( vot ) =diag( vo( vot )) (16)
Hsp(; i) D(aspii; aspij); Hvo(; i) D(avoii; avoij) (17)
Therefore, for givenHnsp1 andHvo
n 1, Bayesian updating can be used to derive the …ltered probabilities of the di¤erent regimes. Then, the multimove Gibbs-sampling of Carter and Kohn (1994) can be used to draw sp;Tn and vo;Tn (see step 4 for a description of method).
Step 2: Sampling the transition matrices (Hsp
n and Hnvo)
Given the draws for the MS state variables sp;Tn and vo;Tn , the transition probabilities are independent ofST
n 1 and the other parameters of the model and have a Dirichlet distribution. For each column ofHsp
n and Hnvo the posterior distribution is given by
Hnsp(; i) D(aiisp+ spii; aspij + spij)
Hnvo(; i) D(aiivo+ voii; avoij + erij)
where spij and vo
ij denote respectively the numbers of transitions from state isp to state jsp
and from stateivoto statejvoand asp
ii; a
sp
ij; avoii; avoij are the parameters describing the prior.
Step 3.a: Sampling the DSGE parameters ( n=f spn; von ; ssng)
Start drawing a new set of parameters from the proposal distribution:#spn N spn 1; csp sp ;
#von N von 1; cvo vo ; #oe
n N oen 1; coe
oe
(if a block optimization algorithm has been used to …nd the posterior mode) or vec(#) N n 1; c . Here is the inverse of the Hessian computed at the posterior mode and cis a scale factor. Ifn = 1, set n 1 = +c , where is the posterior mode estimate of the DSGE parameters. A Metropolis-Hastings algorithm is used to accept/reject #. Conditional on sp;Tn and vo;Tn there is no uncertainty
around the hyperparameters characterizing the state space form model:
yt = D( ss) +ZSt+vt (18)
St = T( spt )St 1+R( spt ) t (19)
t N(0; Q( vot )); Q( vot ) =diag( vo( vot )) (20)
vt N(0; U); U =diag 2y; 2; 2F (21)
Therefore, the Kalman …lter can be used to evaluate the conditional likelihood according to n 1, the old set of parameters, and #, the proposed set of parameters. Then the condi- tional likelihood is combined with the prior distributions of the DSGE parameters. Compute
cut=minf1; rg where
r = ` # sp ; #vo; #ssjYT; sp;T n ; vo;T n ; ::: p(# sp ; #vo; #ss) ` spn 1; von 1; ssn 1jYT; sp;T n ; vo;Tn ; ::: p sp n 1; von 1; ssn 1
Draw a random numberdfrom an uniform distribution de…ned over the interval [0;1]. If
d < r; ( spn; ssn; von) = (#sp; #vo; #ss), otherwise set ( spn; ssn; von) = spn 1; ssn 1; von 1 .
Step 3.b: Sampling the transition matrix used by agents Hm
n
Start drawing a new set of values for the columns of Hm using a Dirichlet distribu-
tion: Hem(; i) D(bm
ii;n 1; bmij;n 1), where bmii;n 1 and bmii;n 1 depend on the columns of Hnm1. This step de…nes the transition probability q HemjHm
n 1 . Then, use a Metropolis-Hastings algorithm to accept/rejectHem. Compute cut=minf1; rg where
r=
` HemjYT;
n; sp;Tn ; ::: p Hem q Hnm1jHem
` Hm
n 1jYT; n; sp;Tn ; ::: p Hnm1 q HemjHnm1
Draw a random numberdfrom an uniform distribution de…ned over the interval [0;1]. If
d < r; Hm
n =Hem, otherwise set Hnm =Hnm1.
Step 4: Sampling the DSGE state vector ST
n
For a given set of DSGE parameters and MS states, (18)-(21) form a state-space model with known hyperparameters. Step 3 returns a …ltered estimate of the state variable: ST
njYT.
The multimove Gibbs-sampling of Carter and Kohn (1994) can be used to draw the whole vector of ST n. Note that: p SnTjYT =p ST;njYT TY1 t=1 p StjSt+1; YT
Therefore, the whole vector ST
njYT can be obtained drawing ST;n from p ST;njYT and
then using a backward algorithm to drawSt;n,t= 1:::T 1. Note that the state space model
(18)-(21) is linear and Gaussian. It follows that:
ST;njYT N ST;njT; PT;njT StjYT; St+1 N St;njt;St+1;; Pt;njt;St+1 where ST;njT = E ST;njYT (22) PT;njT = Cov ST;njYT (23) St;njt;St+1 = E StjY T; S t+1 (24) Pt;njt;St+1 = Cov StjY T; S t+1 (25)
Step 3 returns ST;njT and PT;njT , while St;njt;St+1 and Pt;njt;St+1 can be obtained updat-
ing the estimate of St;n combining St;njt, the …ltered estimate from step 3, with the new
information contained in St+1;n. See Kim and Nelson (1999) for further details.
Step 5
If n < nsim, go back to 1, otherwise stop, wherensim is the desired number of iterations.
Step 1, step 2 and step 3.b when Hm =Hsp =Hsp;m
In this case we cannot draw Hsp
n simply counting the number of transitions across the
MS states, because a change in the transition matrix implies also a change in the law of motion of the DSGE states. Instead, we can apply a Metropolis-Hastings algorithm treating
ST
n 1 as observed data and using the Hamilton …lter to evaluate the likelihood. In this case, de…ne cut=minf1; rg where
r = ` Hesp;mjST n 1; n 1; ::: p Hesp;m q Hnsp;m1 jHesp;m ` Hnsp;m1jST n 1; n 1; ::: p Hnsp;m1 q Hesp;mjH sp;m n 1
As a side product, we obtain …ltered estimates for the MS states and we can use them to draw sp;Tn and vo;Tn with the usual backward drawing algorithm. Finally, Hvo can be drawn
jointly with Hsp;m or according to the standard procedure described above, given that the