msbvar(Y, z=NULL, p, h, lambda0, lambda1, lambda3, lambda4, lambda5, mu5, mu6, qm, alpha.prior=100*diag(h) + matrix(2, h, h), prior=0, max.iter=40, initialize.opt=NULL)
ts()
.z
= NULL
if there are none (the default). 100 * diag(h) + matrix(2, h, h)
, but the
model will be sensitive to this.default=NULL
initialize.msbvar
is called to provide values. User can
specify values as long as they conform to the structure produced by
initialize.msbvar
. szbvar
for details. The steps of the blockwise optimization follow the suggestions of Sims,
Waggoner, and Zha (2008). The joint optimization problem is
partitioned into the following separate blocks. For each block, a
separate call to optim
is made, holding all of the other
blocks constant:
These four blocks are iterated a total of max.iter
times.
Internal to each block, the state-space filtering algorithm for the
regime classifications is computing using compiled Fortran code for
speed. Despite the use of compiled code, this algorithm can take
several minutes to compute.
The user should try multiple starting values and number of iterations to ensure convergence. The algorithm will improve with each step of the optimization, although sometimes this can be very incremental improvement.
The results for posterior sampling via gibbs.msbvar
will
be sensitive to the choice of alpha.prior
. This is the prior
for the independent Dirichlet process for the MS process. Note that
the prior is roughly proportionate to the number of time periods spent
in each regime, since the estimated MS probabilities map to the
duration of the regime via $1/(1-p)$ where $p$ is the
probability of staying in the regime.
This function should NOT be used for inference, since it only finds the
posterior mode of the model. This function is intended to generate
starting values for the Gibbs sampling of the model. See
gibbs.msbvar
for further details of the Gibbs sampling.
Fruhwirth-Schnatter, Sylvia. 2006. Finite Mixture and Markov Switching Models. Springer Series in Statistics New York: Springer.
Kim, Chang-Jin and Charles R. Nelson. 1999. State-Space Models with Regime Switching: Classical and Gibbs-Sampling Approaches with Applications. Cambridge: MIT Press. Sims, Christopher A. and Daniel F. Waggoner and Tao Zha. 2008. "Methods for inference in large multiple-equation Markov-switching models" Journal of Econometrics 146(2):255--274. Sims, Christopher A. and Tao A. Zha. 1998. "Bayesian Methods for Dynamic Multivariate Models" International Economic Review 39(4):949-968. Sims, Christopher A. and Tao A. Zha. 2006. "Were There Regime Switches in U.S. Monetary Policy?" American Economic Review. 96(1):54--81.
gibbs.msbvar
for the MCMC sampler after using
this function, szbvar
for a non-switching, Bayesian VAR
and more details.## Not run:
# # Simple replication of Hamilton (1989) as in
# # Kim and Nelson (1999: 79, 220)
#
# data(HamiltonGDP)
# set.seed(214)
#
# m2 <- msbvar(HamiltonGDP, p=1, h=2,
# lambda0=0.8, lambda1=0.15, lambda3=1, lambda4=0.25,
# lambda5=1, mu5=0, mu6=0, qm=12,
# alpha.prior=c(100, 30)*diag(2) +
# matrix(12, 2, 2), prior=0, max.iter=30,
# initialize.opt=NULL)
#
# # Now plot the filtered probabilities of a recession
# # Compare to Kim and Nelson (1999: 79, 220)
#
# fp.rec <- ts(m2$fp[,1], start=tsp(HamiltonGDP)[1],
# freq=tsp(HamiltonGDP)[3])
# plot(fp.rec)
#
# ## End(Not run)
Run the code above in your browser using DataLab