Learn R Programming

MSTest (version 0.1.9)

MSVARXmdl: Markov-switching vector autoregressive model with exogenous regressors

Description

This function estimates a Markov-switching vector autoregressive model with exogenous regressors.

Usage

MSVARXmdl(Y, p, k, Z, control = list())

Value

List of class MSVARXmdl (S3 object) with model attributes including:

  • y: a (T-p x q) matrix of observations.

  • X: a (T-p x p*q + const) matrix of lagged observations with a leading column of 1s.

  • x: a (T-p x p*q) matrix of lagged observations.

  • resid: a (T-p x q) matrix of residuals.

  • fitted: a (T x q) matrix of fitted values.

  • intercept: a (k x q) matrix of estimated intercepts of each process.

  • mu: a (k x q) matrix of estimated means of each process.

  • beta: a list containing k separate ((1 + p + qz) x q) matrix of estimated coefficients for each regime.

  • betaZ: a (qz x q) matrix of estimated exogenous regressor coefficients.

  • phi: estimates of autoregressive coefficients.

  • Fmat: Companion matrix containing autoregressive coefficients.

  • stdev: List with k (q x q) matrices with estimated standard deviation on the diagonal.

  • sigma: List with k (q x q) matrices with estimated covariance matrix.

  • theta: vector containing: mu and vech(sigma).

  • theta_mu_ind: vector indicating location of mean with 1 and 0 otherwise.

  • theta_sig_ind: vector indicating location of variance and covariances with 1 and 0 otherwise.

  • theta_var_ind: vector indicating location of variances with 1 and 0 otherwise.

  • theta_P_ind: vector indicating location of transition matrix elements with 1 and 0 otherwise.

  • stationary: Boolean indicating if process is stationary if TRUE or non-stationary if FALSE.

  • n: number of observations (same as T).

  • p: number of autoregressive lags.

  • q: number of series.

  • k: number of regimes in estimated model.

  • P: a (k x k) transition matrix.

  • pinf: a (k x 1) vector with limiting probabilities of each regime.

  • St: a (T x k) vector with smoothed probabilities of each regime at each time t.

  • deltath: double with the maximum relative change in vector theta on the last iteration.

  • iterations: number of EM iterations performed to achieve convergence (if less than maxit).

  • converged: Boolean. TRUE if the conv convergence criterion was met before maxit iterations, FALSE otherwise.

  • theta_0: vector of initial values used.

  • init_used: number of different initial values used to get a finite solution. See description of input maxit_converge.

  • msmu: Boolean. If TRUE model was estimated with switch in mean. If FALSE model was estimated with constant mean.

  • msvar: Boolean. If TRUE model was estimated with switch in variance. If FALSE model was estimated with constant variance.

  • control: List with model options used.

  • logLike: log-likelihood.

  • AIC: Akaike information criterion.

  • BIC: Bayesian (Schwarz) information criterion.

  • Hess: Hessian matrix. Approximated using hessian and only returned if getSE=TRUE.

  • info_mat: Information matrix. Computed as the inverse of -Hess. If matrix is not PD then nearest PD matrix is obtained using nearest_spd. Only returned if getSE=TRUE.

  • nearPD_used: Boolean determining whether nearPD function was used on info_mat if TRUE or not if FALSE. Only returned if getSE=TRUE.

  • theta_se: standard errors of parameters in theta. Only returned if getSE=TRUE.

  • trace: List with Lists of estimation output for each initial value used due to use_diff_init > 1.

Arguments

Y

(T x q) vector with observational data.

p

integer for the number of lags to use in estimation. Must be greater than or equal to 0.

k

integer for the number of regimes to use in estimation. Must be greater than or equal to 2.

Z

a (T x qz) matrix of exogenous regressors.

control

List with optimization options including:

  • getSE: Boolean. If TRUE standard errors are computed and returned. If FALSE standard errors are not computed. Default is TRUE.

  • se_method: String determining the standard-error method. Options are "hessian" (default) and "louis" (Louis 1982 expected-information); the Louis method is used automatically as a fallback when the Hessian is ill-conditioned.

  • msmu: Boolean. If TRUE model is estimated with switch in mean. If FALSE model is estimated with constant mean. Default is TRUE.

  • msvar: Boolean. If TRUE model is estimated with switch in variance. If FALSE model is estimated with constant variance. Default is TRUE.

  • init_theta: vector of initial values. vector must contain (1 x q) vector mu, vech(sigma), and vec(P) where sigma is a (q x q) covariance matrix. This is optional. Default is NULL, in which case initVals_MSARmdl is used to generate initial values.

  • method: string determining which method to use. Options are 'EM' for EM algorithm or 'MLE' for Maximum Likelihood Estimation. Default is 'EM'.

  • maxit: integer determining the maximum number of EM iterations.

  • thtol: double determining the convergence criterion for the relative change in the parameter estimates theta between iterations (used when conv is "theta", "both", or "both-A"). Default is 1e-6.

  • ltol: double determining the convergence criterion for the relative change in the log-likelihood between iterations (used when conv is "loglik", "both", "loglik-A", or "both-A"). Default is 1e-7.

  • conv: string determining the EM convergence criterion. "loglik" (the default) stops on the relative change in the log-likelihood; "theta" stops on the relative change in the parameters (the convention of Hamilton (1994) and of earlier versions of this package); "both" requires both, following Krolzig (1997); "loglik-A" and "both-A" replace the log-likelihood test with the Aitken-accelerated criterion of Bohning et al. (1994) and McLachlan and Krishnan (2008). Default is "loglik".

  • maxit_converge: integer determining the maximum number of initial values attempted until solution is finite. For example, if parameters in theta or logLike are NaN another set of initial values (up to maxit_converge) is attempted until finite values are returned. This does not occur frequently for most types of data but may be useful in some cases. Once finite values are obtained, this counts as one iteration towards use_diff_init. Default is 500.

  • use_diff_init: integer determining how many different initial values to try (that do not return NaN; see maxit_converge). Default is 1.

  • mle_stationary_constraint: Boolean determining if only stationary solutions are considered (if TRUE) or not (if FALSE). Default is TRUE.

  • mle_variance_constraint: double used to determine the lower bound on the smallest eigenvalue for the covariance matrix of each regime. Default is 1e-3.

  • mle_theta_low: Vector with lower bounds on parameters (Used only if method = "MLE"). Default is NULL.

  • mle_theta_upp: Vector with upper bounds on parameters (Used only if method = "MLE"). Default is NULL.

References

Dempster, A. P., N. M. Laird, and D. B. Rubin. 1977. “Maximum Likelihood from Incomplete Data via the EM Algorithm.” Journal of the Royal Statistical Society. Series B 39 (1): 1–38..

Böhning, D., E. Dietz, R. Schaub, P. Schlattmann, and B. G. Lindsay. 1994. “The distribution of the likelihood ratio for mixtures of densities from the one-parameter exponential family.” Annals of the Institute of Statistical Mathematics 46 (2): 373–388.

McLachlan, G. J., and T. Krishnan. 2008. The EM Algorithm and Extensions. 2nd ed. Hoboken, New Jersey: John Wiley & Sons.

Krolzig, Hans-Martin. 1997. “The markov-switching vector autoregressive model.”. Springer.

See Also

VARmdl

Examples

Run this code
set.seed(123)
# Define DGP of MS VAR process
mdl_msvar2 <- list(n     = 200, 
                   p     = 1,
                   q     = 2,
                   mu    = rbind(c(5, -2),
                                 c(10, 2)),
                   sigma = list(rbind(c(5.0, 1.5),
                                      c(1.5, 1.0)),
                                rbind(c(7.0, 3.0),
                                      c(3.0, 2.0))),
                   phi   = rbind(c(0.50, 0.30),
                                 c(0.20, 0.70)),
                   k     = 2,
                   P     = rbind(c(0.90, 0.10),
                                 c(0.10, 0.90)))

# Simulate process using simuMSVAR() function
y_msvar_simu <- simuMSVAR(mdl_msvar2)

# Set options for model estimation
control <- list(msmu   = TRUE, 
                msvar  = TRUE,
                method = "EM",
                use_diff_init = 1)
                
# Estimate model
# \donttest{
  y_msvar_mdl <- MSVARmdl(y_msvar_simu$y, p = 1, k = 2, control = control)
  summary(y_msvar_mdl)
# }

Run the code above in your browser using DataLab