Estimating Markov-switching regression models in Stata

Similar documents
Introduction to Markov-switching regression models using the mswitch command

Postestimation commands predict estat Remarks and examples Stored results Methods and formulas

Autoregressive and Moving-Average Models

9) Time series econometrics

Do Markov-Switching Models Capture Nonlinearities in the Data? Tests using Nonparametric Methods

4. MA(2) +drift: y t = µ + ɛ t + θ 1 ɛ t 1 + θ 2 ɛ t 2. Mean: where θ(l) = 1 + θ 1 L + θ 2 L 2. Therefore,

Econometrics. 9) Heteroscedasticity and autocorrelation

Estimating dynamic stochastic general equilibrium models in Stata

Dynamic stochastic general equilibrium models in Stata 15

Title. Description. Remarks and examples. stata.com. stata.com. Introduction to DSGE models. intro 1 Introduction to DSGEs and dsge

Question 1 [17 points]: (ch 11)

A Comparison of Business Cycle Regime Nowcasting Performance between Real-time and Revised Data. By Arabinda Basistha (West Virginia University)

Lecture#17. Time series III

Testing methodology. It often the case that we try to determine the form of the model on the basis of data

Autoregressive models with distributed lags (ADL)

Switching Regime Estimation

Financial Econometrics Using Stata

Testing for Regime Switching in Singaporean Business Cycles

Unemployment Rate Example

10) Time series econometrics

Analyzing spatial autoregressive models using Stata

Time Series. Chapter Time Series Data

Cointegration and Error-Correction

Econ 423 Lecture Notes: Additional Topics in Time Series 1

Non-Markovian Regime Switching with Endogenous States and Time-Varying State Strengths

Stationary and nonstationary variables

xtdpdqml: Quasi-maximum likelihood estimation of linear dynamic short-t panel data models

Introduction to Econometrics

Financial Econometrics

Why Has the U.S. Economy Stagnated Since the Great Recession?

1 Linear Difference Equations

Testing for spectral Granger causality

News Shocks: Different Effects in Boom and Recession?

Model and Working Correlation Structure Selection in GEE Analyses of Longitudinal Data

Vector Autogregression and Impulse Response Functions

Program. The. provide the. coefficientss. (b) References. y Watson. probability (1991), "A. Stock. Arouba, Diebold conditions" based on monthly

Arma-Arch Modeling Of The Returns Of First Bank Of Nigeria

ECON/FIN 250: Forecasting in Finance and Economics: Section 7: Unit Roots & Dickey-Fuller Tests

Understanding the multinomial-poisson transformation

ECON/FIN 250: Forecasting in Finance and Economics: Section 8: Forecast Examples: Part 1

The simulation extrapolation method for fitting generalized linear models with additive measurement error

GMM Estimation in Stata

THE UNIVERSITY OF CHICAGO Graduate School of Business Business 41202, Spring Quarter 2003, Mr. Ruey S. Tsay

Problem Set 2: Box-Jenkins methodology

ECON/FIN 250: Forecasting in Finance and Economics: Section 6: Standard Univariate Models

Latent class analysis and finite mixture models with Stata

AR, MA and ARMA models

A Beginner s Introduction. Box-Jenkins Models

STA 6857 ARIMA and SARIMA Models ( 3.8 and 3.9)

CENTRE FOR APPLIED MACROECONOMIC ANALYSIS

Econ 623 Econometrics II Topic 2: Stationary Time Series

A Test for State-Dependent Predictive Ability based on a Markov-Switching Framework

STA 6857 ARIMA and SARIMA Models ( 3.8 and 3.9) Outline. Return Rate. US Gross National Product

7 Introduction to Time Series

Identifying Aggregate Liquidity Shocks with Monetary Policy Shocks: An Application using UK Data

Case of single exogenous (iv) variable (with single or multiple mediators) iv à med à dv. = β 0. iv i. med i + α 1

ECON2228 Notes 10. Christopher F Baum. Boston College Economics. cfb (BC Econ) ECON2228 Notes / 48

ECONOMICS 7200 MODERN TIME SERIES ANALYSIS Econometric Theory and Applications

A lecture on time series

-redprob- A Stata program for the Heckman estimator of the random effects dynamic probit model

ECON2228 Notes 10. Christopher F Baum. Boston College Economics. cfb (BC Econ) ECON2228 Notes / 54

TIME SERIES DATA PREDICTION OF NATURAL GAS CONSUMPTION USING ARIMA MODEL

Y t = log (employment t )

Econometric Forecasting

Spatial Regression Models: Identification strategy using STATA TATIANE MENEZES PIMES/UFPE

1 Introduction. 2 AIC versus SBIC. Erik Swanson Cori Saviano Li Zha Final Project

Measures of Fit from AR(p)

James Morley*, Jeremy Piger and Pao-Lin Tien Reproducing business cycle features: are nonlinear dynamics a proxy for multivariate information?

BEE2006: Statistics and Econometrics

Diagnostic Test for GARCH Models Based on Absolute Residual Autocorrelations

Monday 7 th Febraury 2005

Moreover, the second term is derived from: 1 T ) 2 1

BJEST. Function: Usage:

Univariate linear models

Analysing repeated measurements whilst accounting for derivative tracking, varying within-subject variance and autocorrelation: the xtiou command

Volatility. Gerald P. Dwyer. February Clemson University

A Journey to Latent Class Analysis (LCA)

Obtaining Critical Values for Test of Markov Regime Switching

A Threshold Model of Real U.S. GDP and the Problem of Constructing Confidence. Intervals in TAR Models

7 Introduction to Time Series Time Series vs. Cross-Sectional Data Detrending Time Series... 15

Are recoveries all the same?

Syntax Description Options Remarks and examples Stored results Methods and formulas References Also see

AR(p) + I(d) + MA(q) = ARIMA(p, d, q)

Longitudinal Data Analysis Using Stata Paul D. Allison, Ph.D. Upcoming Seminar: May 18-19, 2017, Chicago, Illinois

Dynamic Time Series Regression: A Panacea for Spurious Correlations

LATVIAN GDP: TIME SERIES FORECASTING USING VECTOR AUTO REGRESSION

This time it is different! Or not? Discounting past data when predicting the future

Stata tip 63: Modeling proportions

Econ 424 Time Series Concepts

IDENTIFYING BUSINESS CYCLE TURNING POINTS IN CROATIA

Univariate Nonstationary Time Series 1

Predicting bond returns using the output gap in expansions and recessions

ECON3327: Financial Econometrics, Spring 2016

Vector Auto-Regressive Models

TAKEHOME FINAL EXAM e iω e 2iω e iω e 2iω

Chapter 4: Models for Stationary Time Series

Lab 11 - Heteroskedasticity

VAR Models and Applications

Stat 5100 Handout #12.e Notes: ARIMA Models (Unit 7) Key here: after stationary, identify dependence structure (and use for forecasting)

TREND ESTIMATION AND THE HODRICK-PRESCOTT FILTER

Transcription:

Estimating Markov-switching regression models in Stata Ashish Rajbhandari Senior Econometrician StataCorp LP Stata Conference 2015 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 1 / 31

ARMA models Time series data are autocorrelated due to the dependence with past values. Autoregressive moving average (ARMA) class of models is a popular tool to model such autocorrelations. The AR part models the current value as a weighted average of past values with some error. y t = φy t 1 + ε t where y t is the observed series φ is the autoregressive parameter ε t is an IID error with mean 0 and variance σ 2 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 2 / 31

ARMA(1,1) model The MA part models the current value as a weighted average of past errors. y t = ε t + θε t 1 where θ is the moving average parameter. The AR and MA models generate completely different autocorrelations. Combining these lead to a flexible way to capture various correlation patterns observed in time series data. y t = φy t 1 + ε t + θε t 1 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 3 / 31

Linear ARMA models Current value of the series is linearly dependent on past values The parameters do not change throughout the sample This precludes many interesting features observed in the data Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 4 / 31

Examples In economics, the average growth rate of gross domestic product (GDP) tend to be higher in expansions than in recessions. Furthermore, expansions tend to last longer than recessions In finance, stock returns display periods of high and low volatility over the course of years In public health, incidence of infectious disease tend be different under epidemic and non-epidemic states Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 5 / 31

Nonlinear models In all these examples, the dynamics are state-dependent. The states may be recession and expansion, high volatility and low volatility, or epidemic and non-epidemic states Parameters may be changing according to the states Nonlinear models aim to characterize such features observed in the data Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 6 / 31

Markov-switching model Hamilton (1989) Finite number of unobserved states Suppose there are two states 1 and 2 Let s t denote a random variable such that s t = 1 or s t = 2 at any time s t follows a first-order Markov process Current value of s t depends only on the immediate past value We do not know which state the process is in but can only estimate the probabilities The process can switch between states repeatedly over the sample Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 7 / 31

Features Estimate the state-dependent parameters Estimate transition probabilities P(s t = j s t 1 = i) = p ij Probability of transitioning from state i to state j Estimate the expected duration of a state Estimate state-specific predictions Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 8 / 31

Background Consider the following state-dependent AR(1) model y t = µ st + φ st y t 1 + ε t where ε t N(0, σ 2 s t ) s t is discrete and denotes the state at time t The parameters µ, φ, and σ 2 are state-dependent The number of states are imposed apriori For example, a two-state model can be expressed as { µ 1 + φ 1 y t 1 + ε t,1 if s t = 1 y t = µ 2 + φ 2 y t 1 + ε t,2 if s t = 2 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 9 / 31

Assumptions on the state variable Recall the two-state model { µ 1 + φ 1 y t 1 + ε t,1 if s t = 1 y t = µ 2 + φ 2 y t 1 + ε t,2 if s t = 2 If the timing when the process switches states is known, we could Create indicator variables to estimate the parameters in different states. For example economic crisis may alter the dynamics of a macroeconomic variable. Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 10 / 31

States are unobserved s t is drawn randomly every period from a discrete probability distribution Switching regresssion model The realization of s t at each period are independent from that of the previous period s t follows a first-order Markov process The current realization of the state depends only on the immediate past s t is autocorrelated Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 11 / 31

mswitch regression command in Stata Markov-switching autoregression mswitch ar depvar [ nonswitch varlist ] [ if ] [ in ], ar(numlist) [ options ] Markov-switching dynamic regression mswitch dr depvar [ nonswitch varlist ] [ if ] [ in ] [, options ] Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 12 / 31

MSAR with 4 lags Hamilton (1989) models the quarterly growth rate of real GNP as a two state model The dataset spans the period 1951q1-1984q4 The states are expansion and recession rgnp t = µ st + φ 1 (rgnp t 1 µ st 1 ) + φ 2 (rgnp t 2 µ st 2 )+ φ 3 (rgnp t 3 µ st 3 ) + φ 4 (rgnp t 4 µ st 4 ) + ε t Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 13 / 31

Quarterly growth rate of US RGNP 1950q1 1951q2 1952q3 1953q4 1955q1 1956q2 1957q3 1958q4 1960q1 1961q2 1962q3 1963q4 1965q1 1966q2 1967q3 1968q4 1970q1 1971q2 1972q3 1973q4 1975q1 1976q2 1977q3 1978q4 1980q1 1981q2 1982q3 1983q4 1985q1-2 -1 0 1 2 3 recession growth rate US RGNP Figure : Quarterly growth rate of US RGNP Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 14 / 31

Markov-switching autoregression. mswitch ar rgnp, ar(1/4) nolog Performing EM optimization: Performing gradient-based optimization: Markov-switching autoregression Sample: 1952q2-1984q4 No. of obs = 131 Number of states = 2 AIC = 2.9048 Unconditional probabilities: transition HQIC = 2.9851 SBIC = 3.1023 Log likelihood = -181.26339 rgnp rgnp Coef. Std. Err. z P> z [95% Conf. Interval] ar L1..0134871.1199941 0.11 0.911 -.2216971.2486713 L2. -.0575212.137663-0.42 0.676 -.3273357.2122933 L3. -.2469833.1069103-2.31 0.021 -.4565235 -.037443 L4. -.2129214.1105311-1.93 0.054 -.4295583.0037155 State1 _cons -.3588127.2645396-1.36 0.175 -.8773007.1596753 State2 _cons 1.163517.0745187 15.61 0.000 1.017463 1.309571 sigma.7690048.0667396.6487179.9115957 p11.754671.0965189.5254555.8952432 p21.0959153.0377362.0432569.1993221 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 15 / 31

Transition probabilities State 1 is recession and State 2 is expansion. Let P denote a transition probability matrix for 2 states. The elements of P are [ ] [ ] p11 p P = 12 0.75 0.25 = p 21 p 22 0.1 0.9 such that j p ij = 1 for i,j = 1,2. p 11 denotes the probability of transitioning to recession in the next period given that the current state is in recession. Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 16 / 31

Predicting the probability of recession 0.2.4.6.8 1 1950q1 1951q2 1952q3 1953q4 1955q1 1956q2 1957q3 1958q4 1960q1 1961q2 1962q3 1963q4 1965q1 1966q2 1967q3 1968q4 1970q1 1971q2 1972q3 1973q4 1975q1 1976q2 1977q3 1978q4 1980q1 1981q2 1982q3 1983q4 1985q1 date (quarters) recession probability of recession Figure : Probability of recession Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 17 / 31

Expected duration Compute the expected duration the series spends in a state Let D i denote the duration of state i D i follows a geometric distribution The expected duration is E[D i ] = 1 1 p ii The closer p ii is to 1, the higher is the expected duration of state i Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 18 / 31

Estimating duration of a state. estat duration Number of obs = 131 Expected Duration Estimate Std. Err. [95% Conf. Interval] State1 4.076159 1.603668 2.107284 9.545916 State2 10.42587 4.101873 5.017005 23.11772 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 19 / 31

Equivalent AR specifications Consider the following equivalent AR(1) models: y t δ = φ(y t 1 δ) + ε t y t = µ + φy t 1 + ε t The unconditional means for the above models are related: δ = µ 1 φ Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 20 / 31

MSAR and MSDR specifications This equivalence is not possible if the mean is state-dependent y t = δ st + φ(y t 1 δ st 1 ) + ε t y t = µ st + φy t 1 + ε t (AR) (DR) A one time change in the state leads to an immediate shift in the mean level in the AR specification. A one time change in the state leads to the mean level changing smoothly over several time periods in the DR specification. Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 21 / 31

State vector of MSAR The observed series depends on the value of states at time t and t 1. A two-state Markov process becomes a four-state Markov process. In general, AR specification increases the state vector by the factor K p+1, where p is the number of lags. Used for modeling data with smaller frequency such as quarterly, annual, etc. Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 22 / 31

Markov-switching model of interest rates interest rate 0 5 10 15 20 1955q1 1967q3 1980q1 1992q3 2005q1 date (quarters) Figure : Short term interest rate Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 23 / 31

Estimating interest rates Estimate using data for the period 1955q3-2005q4 Assume the following specification for interest rates where intrate is the interest rate e st N(0, σ 2 s t ) µ and σ 2 is state-dependent intrate t = µ st + e st Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 24 / 31

Estimate the model using mswitch dr. mswitch dr intrate, varswitch nolog Performing EM optimization: Performing gradient-based optimization: Markov-switching dynamic regression Sample: 1954q3-2005q4 No. of obs = 206 Number of states = 2 AIC = 4.4078 Unconditional probabilities: transition HQIC = 4.4470 SBIC = 4.5048 Log likelihood = -448.00658 intrate Coef. Std. Err. z P> z [95% Conf. Interval] State1 _cons 2.650457.1260721 21.02 0.000 2.40336 2.897554 State2 _cons 7.445134.2649754 28.10 0.000 6.925792 7.964477 sigma1.9704124.0880692.8122805 1.159329 sigma2 2.958272.1824307 2.621478 3.338336 p11.9789357.0160089.9102967.9953235 p21.0193584.0116402.0059.0616132 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 25 / 31

Predicted probability of State 2 0.2.4.6.8 1 1955q1 1967q3 1980q1 1992q3 2005q1 date (quarters) stdintrate probability of State 2 Figure : Predicted probabilities using MSDR model Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 26 / 31

Dynamic forecasting with MSAR Estimate using data for the period 1955q3-1999q4 Assume the following specification for interest rates intrate t = µ st + ρ intrate t 1 + φ st inflation t + γ st ogap t + e t where intrate is the interest rate inflation is the inflation rate ogap is the output gap e t N(0, σ 2 ) ρ is constant µ, φ, and γ are state-dependent Out-of-sample forecasting from period 2000q1-2007q1 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 27 / 31

Estimate the model using mswitch dr. mswitch dr intrate L.intrate if tin(,1999q4), switch(inflation ogap) nolog Performing EM optimization: Performing gradient-based optimization: Markov-switching dynamic regression Sample: 1955q3-1999q4 No. of obs = 178 Number of states = 2 AIC = 2.3301 Unconditional probabilities: transition HQIC = 2.4025 SBIC = 2.5088 Log likelihood = -197.375 intrate Coef. Std. Err. z P> z [95% Conf. Interval] intrate intrate L1..8503947.0991269 8.58 0.000.6561096 1.04468 State1 inflation -.0392848.1298901-0.30 0.762 -.2938646.215295 ogap.1473233.0528794 2.79 0.005.0436816.250965 _cons.7403998.2041607 3.63 0.000.3402522 1.140547 State2 inflation.2688704.0798215 3.37 0.001.1124232.4253177 ogap -.0075103.0856139-0.09 0.930 -.1753105.1602899 _cons.2173127.4685576 0.46 0.643 -.7010433 1.135669 sigma.6138084.0367645.54582.6902655 p11.7459455.2512815.1792104.9752993 p21.2061723.0956226.0763309.4494157 Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 28 / 31

Out-of-sample dynamic forecasts 0 2 4 6 8 2000q3 2002q1 2003q3 2005q1 2006q3 date (quarters) interest rate forecasts in State 1 forecasts in State 2 weighted forecasts Figure : Forecasts using MSDR model Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 29 / 31

Thank you! Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 30 / 31

Hamilton, J. D. (1989), A new approach to the economic analysis of nonstationary time series and the business cycle, Econometrica 57(2), 357 384. Ashish Rajbhandari (StataCorp LP) Markov-switching regression Stata Conference 2015 31 / 31