Learn R Programming

MSBVAR (version 0.7-0)

msvar: Markov-switching vector autoregression (MSVAR) estimator

Description

Estimates a Markov-swtiching vector autoregression (MSVAR) model with $h$ regimes (states) by maximum likelihood. The Hamilton filtering algorithm is used to estimate the regimes. The numerical optimization to compute the MLE is based on the block-wise algorithm of Sims, Waggoner and Zha (2008).

Usage

msvar(Y, p, h, niterblkopt = 10)

Arguments

Value

A list of class MSVAR and the appropriate inputs objects to feed the results into subsequent functions like gibbs.msbvar (though you should use msbvar and specify a prior!).init.modelDescription of 'comp1'hregDescription of 'comp2'Q$h \times h$ Markov transition matrixfp$T \times h$ Transition probability matrixmInteger, number of equationspInteger, number of lagshInteger, number of regimesllfvalVector of length niterblkoptDirectBFGSLastSuccessoptim convergence code returned in the last optimization used in the last block-wise optimization

Details

This function computes ML estimates for an MSVAR(p,h) model where $p$ is the number of lags and $h$ is the number of regimes. The model is estimated using the block-wise algorithm of Sims, Waggoner, and Zha (2008). This ML optimization algorithm splits the parameter space of the MSVAR model into separate block components: (1) the transition matrix $Q$, (2) the intercepts, (3) the autoregressive coefficients, (4) the error covariances. The algorithm does 4 separate optimizations for each niterblkopt calls. Each component of the model is optimized separately over the niterblkopt values using separate calls to optim. Within each optim call, Fortran code is used to do the work of the filtering algorithm for the regimes in the model

References

Hamilton, James. 1989. "A new approach to the economic analysis of nonstationary time series and the business cycle." Econmetrica, 357--384. 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.

See Also

msbvar for the Bayesian estimator, szbvar for the Bayesian, non-regime-switching version, gibbs.msbvar for posterior sampling.

Examples

Run this code
# Simple replication of Hamilton (1989) as in
# Kim and Nelson (1999: 79, 220)

data(HamiltonGDP)
set.seed(1)

m2 <- msvar(HamiltonGDP, p=1, h=2, niterblkopt=20)

# Now plot the filtered probabilities of a recession
# Compare to Kim and Nelson (1999: 79, 220)

fp.rec <- ts(m2$fp[,1], start=tsp(gdp)[1], freq=tsp(gdp)[3])
plot(fp.rec)

Run the code above in your browser using DataLab