MSVAR (Markov-Switching Vector AutoRegressions)

Overview

Contents

Quick Start

Working with MSVAR: Ox 3.4 console version

Working with MSVAR: OxPack

MSVAR download and links

MSVAR modelling

The model

The statistical model of the K-dimensional time series vector yt=(y1t,...,yKt) is defined conditional upon the regime stÎ{1,...,M}. :

p(yt|Yt-1,Xt,st)={
f(yt|Yt-1,Xt,q1) if st=1
    
f(yt|Yt-1,Xt,qM) if st=M.

where p(yt|Yt-1,Xt,st) is the probability density function of the vector of endogenous variables yt=(y1t,...,yKt)' conditional upon the history of the process, Yt-1={yt-i}i=1¥, some (strongly) exogenous variables Xt={xt-i}i=0¥ and the regime variable st.. qm is the parameter vector present in regime m. It is usually assumed that the statistical model is linear in each regime, say st=m. In the following we focus on autoregressive processes

yt=nm+am1yt-1+...+ampyt-p+et,    et~IID(0,sm2),

and their multivariate generalization: the vector autoregressive (VAR) process

yt=nm+Am1yt-1+...+Ampyt-p+et,    et~IID(0,Sm).

Models with shifts in the intercept as above imply a smooth adjustment of the time series after regime shifts. In contrast, there is a once-and-for-all jump in the time series when the conditional process is subject to shifts in the mean:

yt-m(st)=A1(st)( yt-1-m(st-1)) +...+Ap(st)( yt-p-m(st-p)) +ut,

If the stochastic process of yt is defined conditionally upon the (unobservable) regime st, a complete description of the data generating mechanism requires the specification of the stochastic process which generates the regime:
Pr (st|Yt-1,St-1,Xt;r)

where the history St-1={st-j}j=1¥ of the state variable might be unobserved but will be "reconstructed" from the observations and the vector r collects the parameters of the regime generating process. The models within this class differ in their assumptions concerning the stochastic process generating the regime.

Model types

The following types of regime-switching models can be estimated by MSVAR:

Model formulation

The following steps are involved in model formulation:

MSVAR examples

MSVAR exported member functions

The documentation only includes the exported member functions of MSVAR. The non-exported member functions are not documented here as they are only called from other MSVAR function members. Some functions are quite complex, and should be approached with care.

Notation:

K number of endogenous variables,
M number of regimes,
N dimension of the state vector (MSIxx: M, MSMxx: Mp+1)
p order of the VAR,
r cointegration rank
R number of regressors (excluding constant),
T number of observations.

CycleDating

CycleDating();

Description

Reports the regime classification based on the smoothed regime probabilities.

DeSelect

DeSelect();

Description

Clears the model formulation, i.e. clears previous calls to Select() and SetSample().

DynamicAnalysis

DynamicAnalysis();

Description

Prints dynamic analysis.

Estimate

Estimate(const mMu, const mB, const m_mSigma, const Trans);
Estimate(const mProbSt);
Estimate(const );

mMu in: K ×M matrix of means or intercepts (MSAx: K ×1)
mB in: K ×R matrix of coefficients (MSxAx: K ×MR)
mSigma in: K ×M variance matrix (MSxxH: K ×MK)
mTrans in: M ×M transition matrix (transposed matrix of transition probabilities)
mProbSt in: M ×T matrix of initial regime probabilities

Description

Estimates the model and prints the results, unless this is switched off by SetPrint(). Use Select, SetSample and SetModel prior to Estimate to formulate the model.

When initial parameter values or regime probabilities are not given, Estimate() will calculate them.

DrawErrors

DrawErrors(const fAcf);

fAcf in: integer, TRUE: draw error analysis

Description

Calculates and draws the one-step prediction errors yt-E[yt|Yt-1] and standardized residuals of each equation. If fAcf is TRUE a graphic analysis of one-step prediction errors and standardized residuals is undertaken. The error analysis includes the estimated ACF, spectral density, histogram and a QQ plot.

DrawFit

DrawFit();

Description

Draws actual and fitted values for all series.

DrawModelAnalysis

DrawModelAnalysis();

Description

Illustrates some essential properties of the estimated model.

DrawResults

DrawResults();

Description

Draws the series, the Markov chain component as well as the smoothed, filtered and predicted probabilities for all regimes m=1,...,M.

Forecast

Forecast(const h, const fFoTable, const fFoGraph, const fFoCum);

h in: integer, number of periods
fFoTable in: integer, TRUE: print table
fFoGraph in: integer, TRUE: show graphs
fFoCum in: integer, TRUE: cumulates forecasts

Description

Forecasts.

GetA, GetB, GetMu, GetSigma, GetTrans, GetAIC, GetHQ, GetLogLik, GetSC, GetT, GetU, GetProbS, GetProbSt, GetProbF, GetProbFt, GetProbP, GetProbPt, GetProbErg, GetProbInit, GetProbLast, GetEmOptions, GetModel, GetCovar

Description

Return value

GetA() gets VAR matrices
GetAIC() returns Akaike Information Criterion
GetB() returns K ×R matrix of coefficients (MSxAx: K ×MR)
GetCovar() returns variance-covariance matrix of ML estimates
GetEmOptions()returns an array with the EM algorithm options as set using SetEmOptions
GetHQ() returns Hannan Quinn Information Criterion
GetLogLik() returns log-likelihood
GetModel() returns an array with the model options as set using SetModel
GetMu() returns K ×M matrix of means or intercepts (MSAx: K ×1)
GetProbInit() gets M ×1 vector of initial regime probabilies (MSMx: Mp ×1)
GetProbErg() gets M ×1 vector of ergodic regime probabilies
GetProbLast() gets N ×1 vector of smoothed regime probabilies at time T
GetProbF() gets N ×T matrix of filtered regime probabilies
GetProbFt() gets M ×T matrix of filtered regime probabilies
GetProbP() gets N ×T matrix of predicted regime probabilies
GetProbPt() gets M ×T matrix of predicted regime probabilies
GetProbS() gets N ×T matrix of smoothed regime probabilies
GetProbSt() gets M ×T matrix of smoothed regime probabilies
GetSC() returns Schwarz Information Criterion
GetSigma() returns K ×K variance matrix (MSxxH: K ×MK)
GetT() gets number of observations T
GetTrans() returns M ×M transition matrix (transposed matrix of transition probabilities)
GetU() gets K ×NT matrix of residuals

Description

Most of these functions can be only called after the data has been loaded for estimation, or after successful estimation.

Impulse

Impulse(const h, const fIrCum, const fIrOrth);

h in: integer, number of periods
fIrCum in: integer, TRUE: cumulates responses
fIrOrth in: integer, TRUE: orthogonalizes impulses

Description

Draws impulse response functions for MS-VARs.

ImpulseVecm

ImpulseVecm(const mAlpha, const mBeta, const h, const fIrOrth);

mAlpha in: K ×r matrix of adjustment parameters
mBeta in: K ×r matrix of cointegration vectors
h in: integer, number of periods
fIrOrth in: integer, TRUE: orthogonalizes impulses

Description

Draws impulse response functions for MS-VECMs.

IsConverged

IsConverged();

Description

Return value

Returns 1 if the EM algorithm converged, -1 if the algorithm stopped at the maximum number of iteration, and 0 otherwise.

IsOxPack

IsOxPack(const fOxPack);

fOxPack in: integer, FALSE: use MSVAR with the console version of Ox

Description

It is imperative to let MSVAR know that you do not call it via OxPack.

MSVAR

MSVAR();

Description

Constructor function.

MsvarFor

MsvarFor(const mY, const fModel, const cM, const vProb,
         const mMu, const mA, const mTrans, const max_h);

mY in: K ×T data
fModel in: integer, model type
cM in: integer, number of regimes
vProb in: M ×T matrix of initial regime probabilities
mMu in: K ×M matrix of means or intercepts (MSAx: K ×1)
mB in: K ×R matrix of coefficients (MSxAx: K ×MR)
mTrans in: M ×M transition matrix (transposed matrix of transition probabilities)
max_h in: integer, number of periods

Description

Forcasts MS-VAR processes.

MsvecmFor

MsvecmFor(const mY, const fModel, const cM, const vProb,
          const mMu, const mAlpha, const mBeta, mGamma, const pmA,
          const vDelta, const mTrans, const cT, const max_h);              

mY in: K ×T data
fModel in: integer, model type
cM in: integer, number of regimes
vProb in: M ×T matrix of initial regime probabilities
mMu in: K ×M matrix of means or intercepts (MSAx: K ×1)
mAlpha in: K ×r matrix of adjustment parameters
mBeta in: K ×r matrix of cointegration vectors
mGamma in: K ×R matrix of coefficients (MSxAx: K ×MR)
pmA in:
mDelta in: K ×R matrix of coefficients (MSxAx: K ×MR)
mTrans in: M ×M transition matrix (transposed matrix of transition probabilities)
cT in:
max_h in: integer, number of periods

Description

Forecasts MS-VECM processes.

Load, LoadIn7, LoadDht, LoadFmtVar, LoadObs, LoadVar, LoadWks, LoadXls

Load(const sFilename);
LoadIn7(const sFilename); 
LoadDht(const sFilename, const iYear1, const iPeriod1, const iFreq); 
LoadFmtVar(const sFilename);
LoadObs(const sFilename, const cVar,const cObs, const iYear1,
        const iPeriod1, const iFreq, const fOffendMis); 
LoadVar(const sFilename, const cVar,const cObs, const iYear1,
        const iPeriod1, const iFreq, const fOffendMis);
LoadWks(const sFilename);
LoadXls(const sFilename);

sFilename in: string, filename
cVar in: int, number of variables
cObs in: int, number of observations
iYear1 in: int, start year
iPeriod1 in: int, start period
iFreq in: int, frequency
fOffendMis in: int, TRUE: offending text treated as missing value FALSE: offending text skipped

Description

Identical to the functions of the underlying database class:

Load creates the database and loads the specified data file from disk. The file type is derived from the extension.

LoadDht creates the database and loads the specified Gauss data file from disk.

LoadIn7 creates the database and loads the specified GiveWin file (PcGive 7 data file) from disk.

LoadFmtVar creates the database and loads the ASCII file with formatting information from disk. In GiveWin this is called `Data with load info'. Such a file is human-readable, with the data ordered by variable, and each variable preceded by a line of the type:

    > name year1 period1 year2 period2 frequency 

LoadObs and LoadVar create the database and load the specified human-readable data file from disk. The data is ordered by observation (LoadObs), or by variable. Since there is no information on the sample or the variable names in these files, the sample must be provided as function arguments. The variable names are set to Var1, Var2, etc., use Rename to rename the variables.

LoadWks and LoadXLS create the database and load the specified spreadsheet file from disk. A .wks or .wk1 file is a Lotus file, an .xls file is an Excel worksheet.

LogLik

LogLik(const vP, const adFunc, const avScore, const amHess);

vP in: 1 ×1 matrix, with current t
adFunc in: address of variable
out: loglikelihood at t
avScore in: should be 0
amHess in: should be 0
Description

Return value

Returns 1 if the likelihood can be evaluated, 0 otherwise.

Description

Uses the BHLK filter to evaluate the likelihood.

PrintCovar

PrintCovar();

Description

Prints variance-covariance matrix of ML estimates.

PrintStdErr

PrintStdErr();

Description

Prints standard errors.

Select

Select(const iGroup, const aSel);

iGroup in: int, group indicator: Y_VAR, X_VAR, S_VAR, T_VAR
aSel in: array, specifying database name, start lag, end lag

Description

Selects variables by name and with specified lags, and assigns the iGroup status to the selection. The aSel argument is an array consisting of sequences of three values: name, start lag, end lag.

The following types of variables are supported:

Y_VAR dependent and lagged dependent variable
X_VAR exogenous regressors
S_VAR regime variable (st Î{1,...,M})
T_VAR threshold variable
Each Select() adds to the current selection. Use DeSelect() to start afresh. Note: SetSample() checks for data availability; in case of missing observations it uses the largest available sample within the selection.

SetB, SetMu, SetSigma, SetTrans

SetB(const mB);
SetMu(const mMu);
SetSigma(const mSigma);
SetTrans(const mTrans);

mMu in: K ×M matrix of means or intercepts (MSAx: K ×1)
mB in: K ×R matrix of coefficients (MSxAx: K ×MR)
mSigma in: K ×K variance matrix (MSxxH: K ×MK)
mTrans in: M ×M transition matrix (transposed matrix of transition probabilities)

Description

Set parameter matrices of the MS-VAR model.

SetEmOptions

SetEmOptions(const dTol, const iIt);
SetEmOptions(const dTol, const iIt, const iItMsm);

dTol in: double, tolerance level for convergence of the Em algorithm as percentage change of the log-likelihood (1e-6 by default).
cItMsm in: integer, maximum number of iterations of the EM algorithm (100 by default).
cItMsm in: integer, number of internal iterations at each M-step (2 by default).

Description

Specifies options of the EM algorithm. Note that the third option only effects MSMx-VAR models.

SetModel

SetModel(const fModel, const M);

fModel in: integer, specification of the MS-VAR, see below.
M in: integer

Description

Set the specification of the MS-VAR and the number of regimes to be used in the model. Use Select() prior to SetModel() to formulate the model.

The following model specifications are supported:

MSH regime-dependent heteroscedasticity
MSI regime-dependent intercept
MSIH regime-dependent intercept and heteroscedasticity
MSM regime-dependent mean
MSHH regime-dependent mean and heteroscedasticity
MSIA regime-dependent intercept
MSIAH regime-dependent intercept and heteroscedasticity
MSIA regime-dependent intercept
MSIAH regime-dependent intercept and heteroscedasticity
SETAR (self-exciting) threshold autoregression
SR switching regression

Note: The computational burden associated with MSMx-VAR models can be quite high (compared to an MSIx-VAR the factor is Mp where p is the order of the VAR). In general it is not advised to work with a number of regimes M ³4 due to local maxima and parameter inflation.

SetOptions

SetOptions(const fStdErr, const fShowDrawResults, const fSaveDrawWindow);

fStdErr in: integer, TRUE: calculate automatically standard errors
fShowDrawResults in: integer, TRUE: calls automatically DrawResults
fSaveDrawWindow in: integer, TRUE: saves gwg files of all MSVAR graphics

Description

Sets general options for the MSVAR class.

SetPrint

SetPrint(const fPrintResults, const fPrintSteps);

fPrintResults in: int, TRUE or FALSE
fPrintSteps in: int, TRUE or FALSE

Description

Switches printing on (TRUE) or off (FALSE). By default printing is on. If fPrintSteps is TRUE the progress of the EM algorithm is printed after each iteration.

SetSample

SetSample(const iYear1, const iPeriod1, const iYear2,  const iPeriod2);

iYear1 in: integer, start year.
iPeriod1 in: integer, start period.
iYear2 in: integer, end year.
iPeriod2 in: integer, end period.

Description

By default, the whole sample is used. This function selects a subsample in the time dimension. Observations before the specified start sample point and after the end are omitted from estimation.

StdErr

StdErr();

Description

Calculations standard errors based on numerical calculations of the Hessian. If the Hessian is singular the generalized inverse is calculated. As the transition probabilities pij are restricted to the [0,1] interval, the parameters are transformed logits pij= log ( pij/1-pij ) which avoids problems if one or more of the pij is close to the border. If one of the transition parameters is estimated to lie on the border, pijÎ{0,1}, then the parameter is taken as being fixed and eliminated from the parameter vector (under construction).
Note: The computational burden is proportional to the squared number of parameters. For systems with more than 100 parameters it is suggested to turn the automatical calculation off. Use PrintStdErr to print standard errors and t-values.

TestAsy

TestAsy();

Description

Performs the Clements and Krolzig (2003) test for business cycle asymmetries.


© HM Krolzig This file last changed .