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)={ |
|
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.
The following types of regime-switching models can be estimated by MSVAR:
The regime variable is observable:
| Pr (st|Yt-1,St-1,Xt;r) = I( st ) |
where the I( st ) is an indicator function .
In structural change models, `time' is the regime variable:
| I( st )={ |
|
In the threshold autoregressive model, the regime shifts are triggered by an observable, exogenous transition variable xt crossing a threshold c:
|
where et~IID(0,s2). The indicator function I( xt;c) is of the type
| I(x;c)={ |
|
|
where et~IID(0,s2). In the SETAR model, the regime-generating process is not assumed to be exogenous but directly linked to the lagged endogenous variable yt-d.
The unobservable regime variable stÎ{1,...,M} is generated by an ergodic Markov chain defined by the transition probabilities:
|
A major advantage of the MS-VAR is its flexibility, see Krolzig (1997):
MSM specification
MSI specification
m varying
m invariant
n varying
n invariant
Aj invariant
S invariant
MSM--VAR
linear MVAR
MSI--VAR
linear VAR
S varying
MSMH--VAR
MSH--MVAR
MSIH--VAR
MSH--VAR
Aj varying
S invariant
MSMA--VAR
MSA--MVAR
MSIA--VAR
MSA--VAR
S varying
MSMAH--VAR
MSAH--MVAR
MSIAH--VAR
MSAH--VAR
The following steps are involved in model formulation:
Hamilton's model of the US business cycle fostered a great deal of interest in the MS--AR model as an empirical vehicle for characterizing macroeconomic fluctuations, and there have been a number of subsequent extensions and refinements (see the literature discussed in Krolzig, 1997). The model is an MSM(2)-AR(4) of the quarterly percentage change in US real GNP from 1953 to 1984:
|
where ut~NID(0,s2), and the conditional mean m(st) switches between two states:
| m(st)={ |
|
The variance of the disturbance term, s2, is assumed to be the same in both regimes. Thus, contractions and expansions are modelled as switching regimes of the stochastic process generating the growth rate of real GNP. The regimes are associated with different conditional distributions of the growth rate of real GNP, where, for example,the mean is positive in the first regime (`expansion') and negative in the second regime (`contraction'). The transition probabilities are constant:
|
By inferring the probabilities of the unobserved regimes conditional on an available information set, it is then possible to reconstruct the regimes.
In Krolzig (1997), Hamilton's model of the U.S. business cycle is generalized to a Markov-switching vector autoregressive (MS-VAR) time series model. This examples analyzes regime shifts in the stochastic process of economic growth of six major OECD countries over the last three decades. An MSMH(3)-VAR(1) model is applied to six series of quarterly GNP growth rates:
| Dyt' | = |
|
For all countries, business cycles can be identified as regime shifts in the mean growth rate occurring mainly simultaneously across countries.
This example replicates the results of the Markov-switching vector equilibrium correction model (MS-VECM) of US Output and Employment proposed by Krolzig and Toro (1999). An MS-VECM is a vector equilibrium correction model with shifts in the drift d(st) and in the long-run equilibrium m(st):
|
and the innovations ut are conditionally Gaussian, ut|st~NID(0,S(st) ). The parameters d and m depend upon a stochastic, unobservable regime variable stÎ{1,...,M} The stochastic process for generating the unobservable regimes is an ergodic Markov chain defined by the transition
|
By following the two-stage procedure proposed in Krolzig (1996), the cointegration properties of the output, yt, and employment, nt, data are studied within a linear vector autoregressive representation using the maximum likelihood techniques (as provided by the PcFiml class). Conditional on the estimated cointegration matrix, we get the following representation:
|
where zt-1=yt-1-nt-1-g^ t-m has been normalized such that E[zt]=0.
ML estimation of the MSIH-VARX model is then based on the Expectation-Maximization (EM) algorithm of the MSVAR class.
Tiao and Tsay (1994) and Potter (1995) analyse two-regime SETAR models of the quarterly growth rate of US output Dyt of the type:
| Dyt=m(st)+åi=15ai(st)Dyt-i+ut, ut~IID(0,s2(st)) |
where the delay d=2 and the threshold c»0. In the example, we estimate a two-regime SETAR(4) for the Hamilton data set.
In this example, we again consider an AR(4) of the quarterly growth rate of US output Dyt over sample period analysed in the other examples, but now conditioned on the NBER business cycle dating. So regime 1 corresponds to NBER expansions (st=0) and regime 2 to NBER recessions (st=1) .
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.
| 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();
DeSelect();
DynamicAnalysis();
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 |
When initial parameter values or regime probabilities are not given, Estimate() will calculate them.
DrawErrors(const fAcf);
| fAcf | in: | integer, TRUE: draw error analysis |
DrawFit();
DrawModelAnalysis();
DrawResults();
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 |
| 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 |
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 |
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 |
IsConverged();
IsOxPack(const fOxPack);
| fOxPack | in: | integer, FALSE: use MSVAR with the console version of Ox |
MSVAR();
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 |
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 |
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 |
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(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 |
PrintCovar();
PrintStdErr();
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 |
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 |
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) |
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). |
SetModel(const fModel, const M);
| fModel | in: | integer, specification of the MS-VAR, see below. |
| M | in: | integer |
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(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 |
SetPrint(const fPrintResults, const fPrintSteps);
| fPrintResults | in: | int, TRUE or FALSE |
| fPrintSteps | in: | int, TRUE or FALSE |
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. |
StdErr();
TestAsy();
© HM Krolzig This file last changed .