Intro To MSM With STATA
Intro To MSM With STATA
Gustavo Sánchez
StataCorp
Gustavo Sánchez
StataCorp
4 Markov-Switching AR Models
We do not know the current state of the DGP, but we can estimate
the probability of each possible state.
Some examples:
In economics
Asymmetrical behavior over GDP expansions and recessions
(Hamilton 1989).
Exchange rates (Engel and Hamilton 1990).
Interest rates (García and Perron 1996).
Stock returns (Kim et al. 1998).
Models for time series that transition over a set of finite states.
States are unobserved and the process can switch among states
throughout the sample.
yt = µs + εt
Where:
µs = µ1 if s=1
µs = µ2 if s=2
µs = µ3 if s=3
yt = µs + xt α + zt βs + s,t
Where:
yt : Dependent variable
µs : State-dependent intercept
xt : Vector of exog. variables with state invariant coefficients α
zt : Vector of exog. variables with state-dependent coefficients βs
s,t ~iid N(0, σs2 )
Example 1:
Consumer price index for Spain 2011=100
Period: 1961m1 - 2015m8
Source: Banco de España
State1
_cons .2060383 .0089781 22.95 0.000 .1884416 .223635
State2
_cons .0262835 .0027906 9.42 0.000 .020814 .0317529
State3
_cons .1668645 .0430856 3.87 0.000 .0824182 .2513108
State1
_cons .2060383 .0089781 22.95 0.000 .1884416 .223635
State2
_cons .0262835 .0027906 9.42 0.000 .020814 .0317529
State3
_cons .1668645 .0430856 3.87 0.000 .0824182 .2513108
State1
_cons .2060383 .0089781 22.95 0.000 .1884416 .223635
State2
_cons .0262835 .0027906 9.42 0.000 .020814 .0317529
State3
_cons .1668645 .0430856 3.87 0.000 .0824182 .2513108
Example 2:
Fertility rate (total births per woman) for Spain
Period: 1960 - 2013
Source: World Bank
Variables:
D.fertility
ch_mortality
D1. .0632344 .0107531 5.88 0.000 .0421587 .08431
State1
gni_pcapita
D1. .0434944 .0115159 3.78 0.000 .0209236 .0660652
school_access
D1. -1.042254 .1833868 -5.68 0.000 -1.401686 -.6828228
_cons -.058854 .0117087 -5.03 0.000 -.0818027 -.0359054
State2
gni_pcapita
D1. .0647241 .0149331 4.33 0.000 .0354557 .0939925
school_access
D1. -1.15316 .557033 -2.07 0.038 -2.244925 -.0613957
_cons -.0078558 .0089525 -0.88 0.380 -.0254023 .0096907
. test _b[State1:D.school_access]=_b[State2:D.school_access],accumulate
( 1) [State1]D.gni_pcapita - [State2]D.gni_pcapita = 0
( 2) [State1]D.school_access - [State2]D.school_access = 0
chi2( 2) = 1.23
Prob > chi2 = 0.5411
D.fertility
ch_mortality
D1. .048953 .0072042 6.80 0.000 .034833 .0630729
gni_pcapita
D1. .0505516 .0091887 5.50 0.000 .0325422 .068561
school_access
D1. -.6381832 .2571355 -2.48 0.013 -1.142159 -.134207
State1
_cons -.0704097 .0082148 -8.57 0.000 -.0865104 -.054309
State2
_cons .0013952 .0071861 0.19 0.846 -.0126893 .0154798
Transition probabilities
. estat transition
Number of obs = 42
Expected duration
. estat duration
Number of obs = 42
Where:
yt : Dependent variable
µst : State-dependent intercept
Example 3:
Interbank interest rate for Spain
Period: 1989Q4 - 2015Q3
Source: Banco de España
Variables:
estat transition
estat duration
D.
r_interbank Coef. Std. Err. z P>|z| [95% Conf. Interval]
D.r_interb~k
ipc
D1. .1345492 .0430415 3.13 0.002 .0501895 .218909
_cons -.1287786 .0299325 -4.30 0.000 -.1874453 -.0701119
State1
ar
L1. -.5821326 .0868487 -6.70 0.000 -.7523529 -.4119122
State2
ar
L1. .600846 .1133802 5.30 0.000 .3786249 .8230671
. estat transition
Number of obs = 91
. estat duration
Number of obs = 91
D. OPG
r_interbank Coef. Std. Err. z P>|z| [95% Conf. Interval]
r_interbank
ipc
D1. .0765736 .0491625 1.56 0.119 -.0197832 .1729305
_cons -.1778991 .081251 -2.19 0.029 -.3371482 -.0186501
ARMA
ar
L1. .5016758 .126954 3.95 0.000 .2528505 .7505011
ARCH
arch
L1. .3809789 .2505937 1.52 0.128 -.1101757 .8721334
garch
L1. .5630487 .2146123 2.62 0.009 .1424163 .983681
_cons .0227445 .0202104 1.13 0.260 -.0168671 .0623561
4 Markov-Switching AR Models
Engel, C., and J. D. Hamilton. 1990. Long swings in the dollar: Are they in the
data and do markets know it?. American Economic Review 80: 689—713.
Hamilton, J. D. 1989. A new approach to the economic analysis of nonstationary
time series and the business cycle. Econometrica 57: 357—384.
Garcia, R., and P. Perron. 1996. An analysis of the real interest rate under
regime shifts. Review of Economics and Statistics 78: 111—125.
Kim, C.-J., C. R. Nelson, and R. Startz. 1998. Testing for mean reversion in
heteroskedastic data based on Gibbs-sampling-augmented randomization.
Journal of Empirical Finance 5: 115—43.
Lu, H.-M., D. Zeng, and H. Chen. 2010. Prospective infectious disease outbreak
detection using Markov switching models. IEEE Transactions on Knowledge and
Data Engineering 22: 565—577.
Hamaker, E. L., R. P. P. P. Grasman, and J. H. Kamphuis. 2010.
Regime-switching models to study psychological processes. In Individual
Pathways of Change: Statistical Models for Analyzing Learning and
Development, ed. P. C. Molenaar and K. M. Newell, 155—168. Washington, DC:
American Psychological Association