state space models with endogenous ... - indiana...

25
State Space Models with Endogenous Regime Switching Yoosoon Chang a , Fei Tan b,c, , Xin Wei a [This Version: February 24, 2018] a Department of Economics, Indiana University, Wylie Hall Rm 105, 100 S. Woodlawn, Bloomington, IN 47401-7104, USA b Department of Economics, John Cook School of Business, Saint Louis University, 3674 Lindell Boulevard, St. Louis, MO 63108-3397, USA c Interdisciplinary Center for Social Sciences, Zhejiang University, 38 Zheda Road, Hangzhou, 310027, China Abstract This article studies the estimation of state space models whose parameters are switch- ing endogenously between two regimes, depending on whether an autoregressive latent factor crosses some threshold level. Endogeneity stems from the sustained impacts of transition innovations on the latent factor, absent from which our model reduces to one with exogenous regime switching. Due to the flexible form of state space representation, this class of models is vastly broad with straightforward extensions to accommodate multiple regimes and latent factors. We develop a computationally efficient filtering algorithm to estimate the nonlinear model. Calculations are greatly simplified by augmenting the transition system with the latent factor and exploiting the conditionally linear and Gaussian structure. The algorithm is shown to be accu- rate in approximating both the likelihood function and filtered state variables. We also apply the filter to estimate a small-scale dynamic stochastic general equilibrium (DSGE) model with Bayesian methods, and find that the Bayes factor strongly favors the endogenous switching version of the DSGE model over the exogenous case. Over- all, our approach provides a greater scope for understanding the complex interaction between regime switching and measured economic behavior. Keywords: state space model; regime switching; endogeneity; filtering; DSGE model. JEL Classification: C13, C32, E52 Corresponding author. E-mail: [email protected] (F. Tan).

Upload: others

Post on 02-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

State Space Models with Endogenous Regime Switching

Yoosoon Changa, Fei Tanb,c,�, Xin Weia

[This Version: February 24, 2018]

aDepartment of Economics, Indiana University, Wylie Hall Rm 105, 100 S. Woodlawn, Bloomington,

IN 47401-7104, USA

bDepartment of Economics, John Cook School of Business, Saint Louis University, 3674 Lindell

Boulevard, St. Louis, MO 63108-3397, USA

cInterdisciplinary Center for Social Sciences, Zhejiang University, 38 Zheda Road, Hangzhou, 310027,

China

Abstract

This article studies the estimation of state space models whose parameters are switch-

ing endogenously between two regimes, depending on whether an autoregressive latent

factor crosses some threshold level. Endogeneity stems from the sustained impacts

of transition innovations on the latent factor, absent from which our model reduces

to one with exogenous regime switching. Due to the flexible form of state space

representation, this class of models is vastly broad with straightforward extensions

to accommodate multiple regimes and latent factors. We develop a computationally

efficient filtering algorithm to estimate the nonlinear model. Calculations are greatly

simplified by augmenting the transition system with the latent factor and exploiting

the conditionally linear and Gaussian structure. The algorithm is shown to be accu-

rate in approximating both the likelihood function and filtered state variables. We

also apply the filter to estimate a small-scale dynamic stochastic general equilibrium

(DSGE) model with Bayesian methods, and find that the Bayes factor strongly favors

the endogenous switching version of the DSGE model over the exogenous case. Over-

all, our approach provides a greater scope for understanding the complex interaction

between regime switching and measured economic behavior.

Keywords: state space model; regime switching; endogeneity; filtering; DSGE model.

JEL Classification: C13, C32, E52

�Corresponding author. E-mail: [email protected] (F. Tan).

Page 2: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

1 Introduction

In time series analysis, there has been a long tradition in modeling the structural changes in

dependent data as the outcome of a regime switching process [Hamilton (1988, 1989)]. By

introducing an unobserved discrete-state Markov chain governing the regime in place, this class

of models affords a tractable framework for the empirical analysis of nonstationarity that is

inherent in most economic and financial data. Among further developments of the approach,

Kim (1994) made an important extension to the state space representation of dynamic linear

models amenable to classical inference, whereas Chib (1996) presented a full Bayesian analysis

for finite mixture models based on Gibbs sampling. An introductory exposition and overview of

the related literature can be found in the monograph by Kim and Nelson (1999).

Yet despite the popularity and continued success of the Markov switching approach, its main-

tained hypothesis that the regime evolves exogenously and thereby falls completely apart from

the rest of the model is neither realistic in many cases nor innocuous. As argued forcefully in

Chang et al. (2017a), the presence of endogeneity in regime switching is indeed ubiquitous and, if

ignored, may yield substantial bias in the estimates of model parameters. It follows that a more

promising approach to modeling occasional but recurrent regime shifts would admit some form

of endogenous feedback from the behavior of underlying economic fundamentals to the regime

generating process [X. Diebold et al. (1994), Kim (2004, 2009), Kim et al. (2008), Bazzi et al.

(2014), Kang (2014), Kalliovirta et al. (2015), among others].

The purpose of this paper is to introduce a threshold-type endogenous regime switching into

dynamic linear models that can be represented as state space forms. This class of models is

vastly broad, including classical regression models and the popular dynamic stochastic general

equilibrium (DSGE) models as special cases, and thus allows for a greater scope for understanding

the complex interaction between regime switching and measured economic behavior.

Following Chang et al. (2017a), an essential feature of the model is that the data generating

process is switching between two regimes, depending on whether an autoregressive latent factor

crosses some threshold level. In our approach, two sources of random innovations drive the latent

factor and hence the regime change: [i] the internal innovations from the transition equation

that represent the fundamental shocks inside the model; [ii] an external innovation linked to the

measurement equation that summarizes all information outside of the model. Apparently, the

relative importance of the former source determines the degree of endogeneity in regime changes.

The autoregressive nature of the latent factor, on the other hand, makes such endogenous effects

long-lasting—a current shock to the transition equation will impact at a decaying rate on all

future latent factors. Most importantly, regime switching of this type renders the transition

probabilities time-varying as they are all functions of the model’s fundamentals. In the special

case where regime shifts are purely driven by the external innovation, our model reduces to one

with exogenous switching.

2

Page 3: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

A. Federal Funds Rate

1960 1970 1980 1990 2000 0%

10%

20%

0%

10%

B. Monetary Policy Intervention

1960 1970 1980 1990 2000-10%

-5%

0%

5%

Figure 1: Federal funds rate and monetary policy intervention. Notes: Panel A plots the effectivefederal funds rate (blue solid line) and that implied by the Taylor (1993) rule (red dashed line), i �4 � 1.5pπ � 2q � 0.5y, where i denotes the federal funds rate, π the annual inflation rate, and y thepercentage deviation of annual real output from its potential. The black solid line in Panel B depictstheir differential. Shaded bars indicate recessions as designated by the National Bureau of EconomicResearch.

The contributions of this paper are twofold, one methodological and the other substantive.

First, we develop an endogenous-switching Kalman filter based on the algorithm of Kim (1994)

to estimate the overall nonlinear state space model. Calculations as well as extensions to cope

with multiple regimes and latent factors are greatly simplified by augmenting the transition

equation with the law of motion for the latent factors and exploiting the conditionally linear

and Gaussian structure. Unlike simulation-based filters, this avoids sequential Monte Carlo

integration and therefore makes our filter computationally efficient. As a useful by-product

of running the filter, the estimated latent factor can be readily extracted from the augmented

system. Simulation experiment indicates that our filtering algorithm is accurate in approximating

both the likelihood function and filtered state variables.

Second, we apply the filter to estimate an endogenous switching version of the new Keynesian

DSGE model in An and Schorfheide (2007) with the U.S. postwar data, and find its strong

statistical support over the exogenous switching or fixed regime case. Ever since the seminal work

of Clarida et al. (2000), modeling the time variation in monetary policy has remained an active

3

Page 4: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

research agenda for macroeconomists. To that end, the regime switching approach has emerged

nowadays as perhaps the most popular modeling choice in dynamic macro models. However,

scant attention in the literature has been paid to why monetary policy regime has shifted over

time. This paper takes a first step toward filling in the important gap—our estimated DSGE

model implies that about 50%–83% of the U.S. monetary policy shifts can be attributed to

historical monetary interventions, the remainder of which to contemporaneous external shock.

While this attribution is model dependent and may be viewed as suggestive, Figure 1 displays

some empirical evidence of such endogenous feedback mechanism. Panel A makes clear that

the Taylor rule for setting the federal funds rate provides by and large an accurate account

of the postwar U.S. monetary policy. Nevertheless, there exist several persistent and sizable

discrepancies as shown in Panel B—monetary interventions (i.e., surprise changes in the policy

rate) reflecting policy considerations beyond what the Taylor rule mandates. Most evident is the

dramatic loosening of policy under Federal Reserve chairmen Arthur Burns and G. William Miller

in the early and late 1970s, followed by the sustained and severe tightening of policy to fight the

Great Inflation under Paul Volcker in the early 1980s. Economic agents who observe this drastic

policy change would shift their beliefs about monetary policy to a more aggressive regime for

controlling the inflation. The ensuing well-anchored expectation of stable and low inflation in the

near future, in conjunction with the actual monetary stance, ensures price stability thereafter.1

To the best of our knowledge, modeling this channel is novel in the literature.

The rest of the paper is planned as follows. Section 2 describes the state space model and

filtering algorithm. Section 3 illustrates the filter using two examples, a small state space model

with simulated data and a monetary DSGE model with real data. Section 4 concludes. We

also employ the following notation. Let Npa, bq denote the normal distribution with mean a

and variance b, pNp�|a, bq its probability density function, and Φp�q the cumulative distribution

function of Np0, 1q. Moreover, pp�|�q and Pp�|�q denote the conditional density and probability

functions, respectively. Lastly, Y1:T is a matrix that collects the sample for periods t � 1, . . . , T

with row observations y1t.

2 Model and Algorithm

This section introduces the threshold-type endogenous switching setup of Chang et al. (2017a),

which nests the conventional Markov switching as a special case, into the state space form of a

general dynamic linear model. Like any regime switching model, the associated likelihood func-

tion depends on all possible histories of the entire regime path. This history-dependent nature

creates a tight upper bound on the sample size that any exact recursive filter can comb through

1As Chris Sims put it in his comment on Davig and Leeper (2006b), “Most people who think that policychanged dramatically and permanently in late 1979 in the United States believe that it did so because inflationappeared to be running out of control, not because an independently evolving switching process happened to callfor a change at that date.”

4

Page 5: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

within a reasonable amount of time.2 Without appealing to the computationally expensive par-

ticle filter, some approximations would seem inevitable. Building on the ‘collapsing’ method of

Kim (1994) to truncate the full history-dependence, we develop an endogenous switching version

of the Kalman filter to approximate the likelihood function and estimate the unknown parameters

as well as the state variables, including the autoregressive latent factor.

2.1 State Space Model Let yt be a l � 1 vector of observable variables, xt a m� 1 vector

of latent state variables, and zt a k � 1 vector of predetermined explanatory variables. Consider

the following regime-dependent linear state space model

yt � Dpstq � Zpstqxt � F pstqzt � Σ1{2u ut, ut � Np0, Ilq (2.1)

xt � Gpstqxt�1 �MpstqΣ1{2ε εt, εt � Np0, Inq (2.2)

where the measurement equation (2.1) links the observable variables to the state variables subject

to a l�1 vector of measurement errors Σ1{2u ut, the transition equation (2.2) describes the evolution

of the state variables driven by a n � 1 vector of exogenous innovations Σ1{2ε εt, and put, εtq are

mutually and serially uncorrelated at all leads and lags. The coefficient matrices Dp�q, Zp�q, F p�q,Gp�q, and Mp�q are allowed to depend on an index variable st � 1twt ¥ τu driven by a stationary

autoregressive latent factor

wt � αwt�1 � vt, vt � Np0, 1q (2.3)

where 0 ¤ α   1 controls the persistency of regime changes.3 As a result, the model is switching

between regime-0 and regime-1, depending upon whether wt takes a value below or above the

threshold level τ . In what follows, we call wt the regime factor.

Endogeneity in regime switching is introduced as in Chang et al. (2017a), but we allow all

current transition innovations to jointly influence the next period regime through its correlation

with the innovation to wt�1. That is,�� εt

vt�1

� � N

����0n

0

� ,��In ρ

ρ1 1

� � , ρ1ρ   1 (2.4)

where εt � rε1,t, . . . , εn,ts1 and ρ � rρ1, . . . , ρns1 � corrpεt, vt�1q is a vector of correlation parameters

that determines the degree of endogeneity in regime changes—as ρ approaches to one in modulus,

today’s transition innovations impinge more forcefully on tomorrow’s regime factor. This type of

2As noted by Kim (1994), even with two regimes, there would be over 1000 cases to consider by period t � 10.3In linearized DSGE models, (2.2) represents the regime-dependent solution to the model variables, and the

coefficient matrices in (2.1)–(2.2) become sophisticated functions of some structural parameters as well as theregime index. See Section 3.2 for details.

5

Page 6: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

endogenous impacts is not only sustained due to the autoregressive form of wt, but also renders

the transition probabilities time-varying because they are all functions of εt. In particular, as

shown in Chang et al. (2017b), the transition probabilities to regime-0 are given by

p00pεtq � Ppst�1 � 0|st � 0, εtq �³τ?1�α2

�8 Φρpτ � αx{?1 � α2 � ρ1εtqpNpx|0, 1qdxΦpτ?1 � α2q (2.5)

p10pεtq � Ppst�1 � 0|st � 1, εtq �³8τ?1�α2 Φρpτ � αx{?1 � α2 � ρ1εtqpNpx|0, 1qdx

1 � Φpτ?1 � α2q (2.6)

where Φρpxq � Φpx{a

1 � ρ2q. Accordingly, we have p01pεtq � 1�p00pεtq and p11pεtq � 1�p10pεtq.In the special case where εt and vt�1 are orthogonal (i.e., ρ � 0n), (2.5)–(2.6) become constants

and our model reduces to one with exogenous regime switching.

Since ppvt�1|εtq is normal, we can replace vt�1 by

vt�1 �n

k�1

ρkεk,t �gffe1 �

n

k�1

ρ2kηt�1, ηt�1 � Np0, 1q (2.7)

where tεk,tunk�1 and the idiosyncratic innovation ηt�1 are all orthogonal and have unit variance.

On the surface, the residual ηt�1 of projecting vt�1 onto εt appears to be a vague source of regime

change in many economic applications where εt is endowed with certain behavioral interpreta-

tions. But it indeed captures potential misspecification of the transition equation—ideally one

would expect the regime change to be fully driven by εt under the ‘true’ model—that leads to

systematic disparities between latent and observable variables. To some extent ηt plays a role

reminiscent of that of the explanatory variables zt. We therefore focus on the important case

zt � ηt in the subsequent analysis, and treat ηt as an added regressor summarizing all external

information beyond what is contained in pyt, xtq or their lags. Accordingly, we call pεk,t, ηtq the

k-th internal and external innovation, respectively.

To quantify the importance of each source of regime change, iterate forward on (2.3) to obtain

wt�h � αhwt �°hj�1 α

h�jvt�j for h ¥ 1. Combining with (2.7), we have the conditional variance

Vartpwt�hq �n

k�1

ρ2k

h

j�1

α2ph�jqloooooomoooooondue to εk

��

1 �n

k�1

ρ2k

�h

j�1

α2ph�jqloooooooooooooomoooooooooooooondue to η

�h

j�1

α2ph�jqloooomoooontotal

, h ¥ 1 (2.8)

It follows directly that the percent of the h-step ahead forecast error variance of the regime

factor due to the k-th internal (or external) innovation is given by ρ2k (or 1�°nk�1 ρ

2k), which is

independent of h. Letting hÑ 8, ρ2k (or 1�°nk�1 ρ

2k) also measures the percentage contribution

to the unconditional variance of the regime factor and hence the extent to which the k-th internal

6

Page 7: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

(or external) innovation contributes to the regime changes. For example, using a new Keynesian

DSGE model with endogenous regime switching, Section 3.2 presents an empirical calculation on

how much of the U.S. monetary policy shifts can be attributed to past monetary interventions.

2.2 Filtering Algorithm Estimating the state space model (2.1)–(2.2) entails the dual

objectives of likelihood evaluation and filtering, both of which require the calculation of inte-

grals over the unobserved state variables (i.e., xt and wt). While the system is linear in xt and

driven by Gaussian innovations, complication arises from the presence of wt; it introduces ad-

ditional nonlinearities into the overall model structure that invalidate evaluating these integrals

via the standard Kalman filter. Nevertheless, approximate analytical integration is still possible

from a marginalization-collapsing procedure. In the marginalization step, we integrate out the

state variables by exploiting the linear and Gaussian structure conditional on the most recent

regime history, for which the standard Kalman filter can be applied. In the collapsing step, we

approximate an otherwise exponentially growing number of history-dependent filtered distribu-

tions by a constant number of mixture Gaussian distributions in each period. This reduction

effectively breaks the full history-dependence of the likelihood function and therefore makes the

computation highly efficient. We call the resulting algorithm the endogenous-switching Kalman

filter.

The key to operationalizing the above two-step procedure is an appropriate augmentation of

the state space model. To that end, we introduce a dummy vector dt and augment the state

vector ςt � rx1t, d1t, wts1 as well as the shock vector ξt � rε1t, ηts1.4 Accordingly, we augment the

transition equation (2.2) by the identity dt � ξt and the law of motion for wt (2.3) so that�����xt

dt

wt

���� loomoonςt

�����Gpstq 0m�pn�1q 0m�1

0pn�1q�pm�n�2q

01�m ρ1 0 α

���� loooooooooooooooomoooooooooooooooonrGpstq

�����xt�1

dt�1

wt�1

���� looomooonςt�1

�����MpstqΣ1{2

ε 0m�1

In�1

01�n?

1 � ρ1ρ

���� loooooooooooooomoooooooooooooon�Mpstq

��εtηt

� loomoonξt

(2.9)

where ξt � Np0, In�1q. To accommodate the expanded state vector in the measurement equation

(2.1), we also redefine the coefficient matrix linking the states to the observables as rZpstq �rZpstq, 0l�n, F pstq, 0l�1s. Moreover, further augmentation of (2.9) allows for straightforward ex-

tensions of the model in the presence of multiple latent factors and hence regimes.

Our main filtering algorithm, which is based on the augmented state space system, dates one

period back to track regime indices in each recursion. At an exponentially rising computation

cost though, one may improve the approximation by tracking even earlier regime history beyond

4The inclusion of dt accommodates the one-period lag in the timing of εt in driving wt�1. Otherwise, oneneeds to augment the state vector as ςt � rx1t, wt�1s

1, whose filtered distribution only gives ppwt�1|Y1:tq ratherthan ppwt�1|Y1:t�1q.

7

Page 8: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

the current and last periods and, in the end, recover the exact likelihood function. For notational

ease, define the predictive and filtered probabilities of regime-j at period t, joint with regime-i at

period t� 1, as ppi,jqt|t�1 � Ppst�1 � i, st � j|Y1:t�1q and p

pi,jqt|t � Ppst�1 � i, st � j|Y1:tq, respectively.

Also define the filtered marginal probability of regime-j at period t as pjt|t � Ppst � j|Y1:tq. Then

the filter can be summarized by the following steps.

Algorithm 1. (Endogenous-Switching Kalman Filter)

1. Initialization. For i � 0, 1, initialize the regime-dependent mean and covariance of ς0,

pς i0|0, P i0|0q, using the invariant distribution under regime-i. Also set p00|0 � Φpτ?1 � α2q

and p10|0 � 1 � p00|0 according to the invariant distribution of w0 (i.e., Np0, 1{p1 � α2qq).

2. Recursion. For t � 1, . . . , T , the filter accepts two sets of triple inputs tpς it�1|t�1, Pit�1|t�1,

pit�1|t�1qu1i�0, invokes the one-step Kalman filter to calculate the required integrals condi-

tional on four possible mixes of the current and last period regimes, and returns two sets

of updated triple outputs tpςjt|t, P jt|t, p

jt|tqu1j�0.

(a) Forecasting. First, apply the Kalman filter forecasting step for state variables to

obtain

ςpi,jqt|t�1 � rGpst � jqς it�1|t�1 (2.10)

Ppi,jqt|t�1 � rGpst � jqP i

t�1|t�1rGpst � jq1 � �Mpst � jq�Mpst � jq1 (2.11)

Next, let pςpi,jqw,t|t�1, Ppi,jqw,t|t�1q be the last and lower right corner elements of pςpi,jqt|t�1, P

pi,jqt|t�1q

corresponding to wt, respectively. Since the last equation (i.e., the law of motion

for wt) in the augmented transition equation (2.9) remains regime invariant, we can

approximate ppwt|st�1 � i, Y1:t�1q by the normal distribution with mean ςpi,jqw,t|t�1 and

variance Ppi,jqw,t|t�1 for any j. Thus

ppi,0qt|t�1 � Φ

�pτ � ς

pi,0qw,t|t�1q{

bPpi,0qw,t|t�1

pit�1|t�1 (2.12)

and ppi,1qt|t�1 � pit�1|t�1 � p

pi,0qt|t�1.

(b) Likelihood evaluation. Apply the Kalman filter forecasting step for observable

variables to obtain

ypi,jqt|t�1 � Dpst � jq � rZpst � jqςpi,jqt|t�1 (2.13)

Fpi,jqt|t�1 � rZpst � jqP pi,jq

t|t�1rZpst � jq1 � Σu (2.14)

8

Page 9: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Then the period-t likelihood contribution can be computed as

ppyt|Y1:t�1q �1

j�0

1

i�0

pNpyt|ypi,jqt|t�1, Fpi,jqt|t�1qppi,jqt|t�1 (2.15)

(c) Updating. First, apply the Bayes formula to update

ppi,jqt|t �

pNpyt|ypi,jqt|t�1, Fpi,jqt|t�1qppi,jqt|t�1

ppyt|Y1:t�1q (2.16)

and calculate pjt|t �°1i�0 p

pi,jqt|t . Next, apply the Kalman filter filtering step to obtain

ςpi,jqt|t � ς

pi,jqt|t�1 � P

pi,jqt|t�1

rZpst � jq1pF pi,jqt|t�1q�1pyt � y

pi,jqt|t�1q (2.17)

Ppi,jqt|t � P

pi,jqt|t�1 � P

pi,jqt|t�1

rZpst � jq1pF pi,jqt|t�1q�1 rZpst � jqP pi,jq

t|t�1 (2.18)

To avoid a twofold increment in the number of cases to consider for the next period,

collapse pςpi,jqt|t , Ppi,jqt|t q into5

ςjt|t �1

i�0

ppi,jqt|tpjt|t

ςpi,jqt|t , P j

t|t �1

i�0

ppi,jqt|tpjt|t

�Ppi,jqt|t � pςjt|t � ς

pi,jqt|t qpςjt|t � ς

pi,jqt|t q1

�(2.19)

Further collapsing pςjt|t, P jt|tq into

ςt|t �1

j�0

pjt|tςjt|t, Pt|t �

1

j�0

pjt|t

�P jt|t � pςt|t � ςjt|tqpςt|t � ςjt|tq1

�(2.20)

gives the filtered state variables.

3. Aggregation. The likelihood function is given by ppY1:T q �±T

t�1 ppyt|Y1:t�1q.

Several remarks about this filtering algorithm are in order. First, due to the augmentation,

the last element of the filtered state vector ςt|t automatically gives an estimated autoregressive

regime factor wt|t as a useful by-product of running the filter. Second, while the general structure

resembles that of the mixture Kalman filter in Chen and Liu (2000), our filter requires no sequen-

tial Monte Carlo integration and is thus computationally efficient. By analytically integrating

out wt and hence st, it also greatly simplifies estimating the model via classical or Bayesian

approaches that would otherwise require a stochastic version of the expectation-maximization

5If pjt|t � 0, the conditional probability ppi,jqt|t {pjt|t � Ppst�1 � i|st � j, Y1:tq in (2.19) is not well defined. In this

case, we set pςjt|t, Pjt|tq � pς1�jt|t , P 1�j

t|t q.

9

Page 10: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

algorithm or Gibbs sampling, respectively [Wei and Tanner (1990), Tanner and Wong (1987)].

Third, in line with Kim (1994), the collapsing step (2.19) involves an approximation—its in-

put ςpi,jqt|t does not calculate the conditional expectation Erςt|st�1 � i, st � j, Y1:ts exactly since

ppςt|st�1 � i, st � j, Y1:tq amounts to a mixture of Gaussian distributions for t ¡ 2. Conse-

quently, the period-t likelihood and filtered states pppyt|Y1:t�1q, ςt|tq only approximately calculate

their true values, whose accuracy will be examined in the next section. Fourth, including ηt

in the measurement equation as an added regressor kills two birds with one stone. Besides the

role of accounting for potential model misspecification, this allows the external source of regime

change to bear more directly on the model’s observables than it would as a purely exogenous

innovation, thereby enhancing the efficiency gain of filtering through the augmented system.6

3 Examples

We apply the endogenous-switching Kalman filter to two examples. First, we consider a small

state space model with simulated observations that serves as a test bench for assessing the

accuracy of our filter in approximating the likelihood function and filtered state variables. Second,

we embed the filter into a Metropolis-Hastings posterior sampler and estimate a prototypical new

Keynesian DSGE model with real data.

3.1 Simulation Model Consider the following small state space model that resembles the

general structure of (2.1)–(2.2) for reduced-form DSGE models

yt ��

1 0��x1,t

x2,t

� � fηt � σuut (3.1)

��x1,tx2,t

� ���g11pstq g12pstq

0 g22

� ��x1,t�1

x2,t�1

� ���0

1

� σεεt (3.2)

where two parameters in the transition equation, pg11, g12q, are allowed to switch between regime-

0 and regime-1. We simulate 100 observations of yt by setting pg11, g12q � p0.8, 0.5q if st � 1

and p0.5, 0.8q otherwise, g22 � 0.9, f � 0.2, pσu, σεq � p0.2, 0.5q, and pα, τ, ρq � p0.9,�0.5, 0.8q.7Overall the model underwent frequent regime changes, on average about once every 3 periods,

which poses a potential challenge to our filter in delivering a satisfactory approximation to the

likelihood function. To evaluate its performance, we estimate the exact likelihood and filtered

states from a regime switching version of the bootstrap particle filter in Gordon et al. (1993).

6Without its inclusion, the Kalman gain of ηt in (2.17)–(2.18), though not necessarily true for exact filters,becomes identically zero in our filter, leading to a zero filtered value of ηt.

7A small measurement error is included so that the data density, conditioned on the states, remains non-degenerate in the particle filter.

10

Page 11: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

It numerically integrates out tpxt, wtquTt�1 using a discrete set of particles simulated from the

transition equations in xt and wt, respectively.8 Our particle filtering algorithm is implemented

through the following steps.

Algorithm 2. (Endogenous-Switching Particle Filter)

1. Initialization. For j � 0, 1, initialize pxj0|0, P j0|0, p

j0|0q as in Algorithm 1 but based on the

original state space form (2.1)–(2.2). For i � 1, . . . , N , draw an initial swarm of particles xi0from the mixture Gaussian distribution p00|0 �Npx00|0, P 0

0|0q� p10|0 �Npx10|0, P 10|0q, εi0 � Np0, Inq,

and wi0 � Np0, 1{p1 � α2qq. Also, set the corresponding weight W i0 � 1{N .

2. Recursion. For t � 1, . . . , T :

(a) Propagation. Draw particles twituNi�1 from

wit � αwit�1 �n

k�1

ρkεik,t�1 �

gffe1 �n

k�1

ρ2kηit, ηit � Np0, 1q (3.3)

and compute tsituNi�1. Then draw particles txituNi�1 from

xit � Gpsitqxit�1 �MpsitqΣ1{2ε εit, εit � Np0, Inq (3.4)

(b) Likelihood. The period-t likelihood integral can be approximated as

ppyt|Y1:t�1q �N

i�1

W it�1ppyt|sit, xitq (3.5)

where ppyt|sit, xitq can be evaluated from the measurement equation.

(c) Filtering. Update the weights according to the Bayes’ Theorem

W it �

W it�1ppyt|sit, xitqppyt|Y1:t�1q (3.6)

(d) Resampling. Define the effective sample size ESS � 1{°Ni�1pW i

t q2. If ESS   N{2,

resample the particles tpxit, εit, witquNi�1 with the systematic resampling scheme and set

W it � 1{N for i � 1, . . . , N . Now the particle system tpxit, εit, wit,W i

t quNi�1 approximates

8A complete tutorial on basic and advanced particle filtering methods can be found in Doucet and Johansen(2011). See also DeJong and Dave (2007) and Herbst and Schorfheide (2015) for textbook treatments of theparticle filter in DSGE applications.

11

Page 12: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

0 20 40 60 80 100-1.5

-1

-0.5

0

0.5A. x1;tjt

0 20 40 60 80 100-1.5

-1

-0.5

0

0.5

1B. x2;tjt

0 20 40 60 80 100-3

-2

-1

0

1

2C. wtjt

0 20 40 60 80 100-6

-5

-4

-3

-2

-1

0D. log p(yt)

Figure 2: Filtered state variables and likelihood decomposition at the true parameter values. Notes:The regime change occurs 32 times out of 100 periods. Panels A–C plot the filtered state variablescomputed from endogenous-switching Kalman filter (red solid line) and a single run of particle filter(blue dash-dotted line). The black dashed line in Panel C delineates the threshold level. Panel Dplots the log likelihood contributions in each period evaluated with both filters (-78.90 and -78.45 inaggregate, respectively).

any filtered value by

Erfpxt, εt, wtq|Y1:ts � plimNÑ8

N

i�1

W it fpxit, εit, witq (3.7)

3. Aggregation. The pseudo likelihood function is given by ppY1:T q �±T

t�1 ppyt|Y1:t�1q.Practically it turns out that N � 100, 000 particles are more than sufficient to accurately

approximate the density ppY1:T q implied by the simulation model, which we take as ‘exact’.

Evaluating at the true parameter values, Figure 2 depicts the filtered state variables (Panels

A–C) and log likelihood decomposition by period (Panel D) computed from the endogenous-

switching Kalman filter and particle filter. A visual comparison suggests that our filter performs

fairly well as it delivers barely distinguishable approximations to these quantities from their true

values. That accuracy extends to a wide range of the parameter space as can be seen in Figure

12

Page 13: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

0 0.2 0.4 0.6 0.8 0.99-90

-88

-86

-84A. g11(0)

0 0.2 0.4 0.6 0.8 0.99-95

-90

-85

-80B. g11(1)

0 0.2 0.4 0.6 0.8 1-88

-86

-84

-82C. g12(0)

0 0.2 0.4 0.6 0.8 1-95

-90

-85

-80D. g12(1)

0 0.2 0.4 0.6 0.8 0.99-110

-100

-90

-80E. g22(0)

0 0.2 0.4 0.6 0.8 0.99-95

-90

-85

-80E. g22(1)

0 0.2 0.4 0.6 0.8 0.99-92

-90

-88

-86

-84G. ,

-5 -2.5 0 2.5 5-120

-110

-100

-90

-80H. =

0 0.2 0.4 0.6 0.8 0.99-95

-90

-85

-80I. ;

Figure 3: Profile of log likelihood functions. Notes: Each panel plots the log likelihood function of anindividual parameter computed from Algorithm 1 (red solid line), Algorithm 2 (blue dash-dotted line),and Algorithm 3 (black dashed line) while holding others at their true values.

3, though the particle filter has some difficulty evaluating the log likelihood functions of certain

parameters near the boundaries.9 In addition, the log likelihood function of each individual

parameter peaks in the immediate vicinity of its true value. Taken together, our filter ensures

the overall likelihood surface is well preserved.

We conclude this section by highlighting the efficiency gain of filtering through the augmented

system. To the extent that allowing for more history-dependence improves accuracy, we also

compare the performance of our filter to its simplified version (Algorithm 3 in the appendix)

that tracks only the current period regime in each recursion. Because augmentation introduces

interactive learning between xt and wt from the data, Figure 3 makes clear that even this ‘mem-

oryless’ filter lends itself well to approximating the log likelihood function.

3.2 Empirical DSGE Model We consider the small-scale new Keynesian DSGE model pre-

sented in An and Schorfheide (2007), whose essential elements include: a representative household

9This is because the particle generating distributions, ppxit|xit�1q and ppwit|w

it�1q, are simply based on the

transition equations in xt and wt, which ignore the information in light of yt. Refinements of the bootstrapparticle filter abound in the literature. For example, one efficient choice is to generate particles from the filteredstate distributions computed from our endogenous-switching Kalman filter and reweigh these particles throughan importance sampling step, the so-called adaptation of the particle filter.

13

Page 14: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

and a continuum of monopolistically competitive firms; each firm produces a differentiated good

and faces nominal rigidity in terms of quadratic price adjustment cost; a cashless economy with

one-period nominal bonds; a monetary authority that controls the nominal interest rate Rt as

well as a fiscal authority that consumes gt and passively adjusts lump-sum taxes to ensure its

budgetary solvency; a labor-augmenting technology that induces a stochastic trend in output yt.

Let xt � lnpxtq � lnpx�q denote the log-deviation of a variable xt from its steady state x�. In the

fixed-regime benchmark, a linear approximation to the model’s equilibrium conditions in terms

of the detrended variables is summarized as follows.

First, the household’s optimizing behavior, when imposed by the goods market clearing con-

dition, implies

yt � Etryt�1s � gt � Etrgt�1s � 1

φpRt � Etrπt�1s � Etrzt�1sq (3.8)

where φ ¡ 0 is the relative risk aversion, πt is the inflation between periods t� 1 and t, zt is an

exogenous shock to the labor-augmenting technology that grows on average at the rate γ, and Etrepresents mathematical expectation given information available at time t. The firm’s optimal

price-setting behavior reduces to

πt � βEtrπt�1s � κpyt � gtq (3.9)

where 0   β   1 is the discount factor and κ ¡ 0 is the slope of the so-called new Keynesian

Phillips curve. Second, the monetary authority follows an interest rate feedback rule that reacts

to deviations of inflation from its steady state and output from its potential value

Rt � ρRRt�1 � p1 � ρRqψππt � p1 � ρRqψypyt � gtq � εR,t (3.10)

where 0 ¤ ρR   1 determines the degree of interest rate smoothing, ψπ ¡ 0 and ψy ¡ 0 are the

policy rate responsive coefficients, and εR,t is an exogenous policy shock. Finally, both gt and zt

evolve as autoregressive processes

gt � ρggt�1 � εg,t, zt � ρz zt�1 � εz,t (3.11)

where 0 ¤ ρg, ρz   1. The model is driven by the three innovations εt � rεR,t, εg,t, εz,ts1 that are

serially uncorrelated, independent of each other at all leads and lags, and normally distributed

with means zero and standard deviations pσR, σg, σzq, respectively. Subsequently, we solve the

linear rational expectations system (3.8)–(3.11) in the state variables xt � ryt, πt, Rt, gt, zts1 using

the procedure of Sims (2001).

There has been ample empirical evidence of time variation in estimated monetary policy rules

14

Page 15: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

documented in the literature. In that vein and for the purpose of illustrating our filter, we

also consider two simple regime switching extensions of the model.10 In the conventional Markov

switching case, the response of policy rate to inflation deviations is switching between, in Leeper’s

(1991) terminology, more ‘active’ and less ‘active’ (or possibly ‘passive’) monetary regimes

ψπpstq � ψ0πp1 � stq � ψ1

πst, 0 ¤ ψ0π   ψ1

π (3.12)

where the regime index st evolves exogenously according to pij � Ppst � j|st�1 � iq for i, j � 0, 1

and°j pij � 1. On the other hand, when st � 1twt ¥ τu so that the transition probabilities

become an important part of the model solution, we assume the endogeneity in regime changes

arises solely from the policy shock, corrpεg,t, vt�1q � corrpεz,t, vt�1q � 0, and a surprise monetary

contraction tends to reinforce agents’ belief of staying in or switching to the more active regime

in the future, corrpεR,t, vt�1q � ρ P r0, 1s, which is motivated by the empirical evidence alluded

to earlier. Interested readers are referred to Chang et al. (2017b) for a more comprehensive

investigation of the macroeconomic origins that give rise to monetary policy shifts. In both

cases we abstract from sources of time variation in the model structure other than that from

the policy parameter ψπpstq.11 Note that the presence of st poses keen computational challenges

to solving the model. In what follows, we obtain the first-order solution using the perturbation

method of Barthelemy and Marx (2017) that is well-suited for solving regime-switching rational

expectations models with state-dependent transition probabilities.12

All three models are estimated with Bayesian methods using a common set of quarterly ob-

servations, ranging from 1954:Q3 to 2007:Q4: per capita real output growth (YGR), annualized

inflation rate (INF), and effective federal funds rate (INT). The actual data is constructed as

in Appendix B of Herbst and Schorfheide (2015), available from the Federal Reserve Economic

Data (FRED). The observable variables are linked to the model variables through the following

10Our paper complements recent likelihood-based estimation of DSGE models with exogenous Markov switchingin monetary policy, including Schorfheide (2005), Bianchi (2013), Davig and Doh (2014), Bianchi and Ilut (2017),and Bianchi and Melosi (2017), among others. Using the same endogenous switching approach as in this paper,Chang and Kwak (2017) also estimated a reduced-form model of monetary-fiscal regime changes.

11Initiated by Sims and Zha (2006), allowing for regime switching in both policy rules and shock volatilities hasalso come under scrutiny in DSGE models, but would require introducing multiple latent factors to operationalizein our setup, which is beyond the scope of this paper.

12Chang et al. (2017b) compute the time-varying transition probabilities implied by the threshold-type regimeswitching adopted in this paper, which is a prerequisite to applying the solution technique of Barthelemy andMarx (2017). An important precursor to our study is Davig and Leeper (2006a), who employ the projectionmethod to solve and calibrate a new Keynesian model where monetary policy rule changes whenever laggedinflation crosses some threshold level.

15

Page 16: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

measurement equations�����YGRt

INFt

INTt

���� �

�����γpQq

πpAq

πpAq � rpAq � 4γpQq

���� � 100

�����yt � yt�1 � zt

4πt

4Rt

���� ������fy

fR

���� ηt (3.13)

where pγpQq, πpAq, rpAqq are connected to the model’s steady states via γ � 1 � γpQq{100, β �1{p1 � rpAq{400q, and π � 1 � πpAq{400. In conjunction with the model solutions under fixed

regime, exogenous and endogenous switching, this can be cast into the state space form (2.1)–

(2.2) and evaluated with the standard Kalman filter, the exogenous switching filter of Kim (1994),

and our endogenous switching filter in Algorithm 1, respectively.13

Table 1 summarizes the marginal prior distributions on the DSGE structural parameters. For

the steady state parameters, the prior means of γpQq and πpAq are calibrated to match the sample

averages of YGR and INF, respectively, and that of rpAq translates into a β value of 0.998.

The priors on the structural shock processes are harmonized: the autoregressive coefficients

pρR, ρg, ρzq are beta distributed with mean 0.5 and standard deviation 0.2; the standard deviation

parameters pρR, ρg, ρzq, all scaled by 100, follow inverse-gamma type-I distribution with mean 0.5

and standard deviation 0.26. Furthermore, the priors on the private sector parameters pφ, κq and

the fixed regime policy responses pψπ, ψyq are largely adopted from An and Schorfheide (2007),

whereas those on the switching parameters pψ0π, ψ

1πq and the transition probabilities pp00, p11q

closely follow the specification in Davig and Doh (2014), which a priori rule out the possibility

of ‘label switching’. Finally, turning to the parameters for the autoregressive regime factor,

the prior on α centers at a rather persistent value that, together with a ‘fair’ prior on τ , implies

transition probabilities comparable to pp00, p11q under exogenous switching.14 On the other hand,

the uniform distribution on ρ reflects an agnostic prior view about the degree of endogeneity in

regime switching. To account for potential model misspecification, we place normal distributions

on the external parameters pfy, fπ, fRq in the measurement equation with mean zero and standard

deviation set to 20% of the sample standard deviation of the corresponding variable.

For each model, we sample a total of 1.1 million draws from the posterior distribution using the

random walk Metropolis-Hastings algorithm, discard the first 100,000 draws as burn-in phase,

and keep one every 100 draws afterwards.15 The resulting 10,000 draws form the basis for the

posterior inference. We highlight several aspects of the posterior estimates reported in Tables

13To conserve space, we do not report estimation results using Algorithm 3 in the appendix since they arequantitatively similar to those in Table 1.

14Chang et al. (2017a) established an important one-to-one mapping between pp00, p11q and pα, τq under ρ � 0.15The acceptance rates range from 32% to 38% across all models. Diagnostics to check the convergence of

Markov chains include graphical methods such as recursive means plot and the separated partial means testproposed by Geweke (1992). See Herbst and Schorfheide (2015) for a detailed textbook treatment of Bayesianestimation of DSGE models.

16

Page 17: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Table 1: Prior and Posterior Estimates of DSGE Models

Prior Distribution Posterior Mean

Parameter Density Para (1) Para (2) Fixed Exogenous Endogenous

Fixed Regime

φ G 2.00 0.50 4.07 2.25 2.75

κ G 0.20 0.10 0.35 0.81 0.21

ψπ G 1.50 0.25 1.15 – –

ψy G 0.50 0.10 0.48 0.49 0.46

rpAq G 0.50 0.10 0.46 0.48 0.42

πpAq G 3.84 2.00 3.34 2.59 3.37

γpQq N 0.47 0.10 0.39 0.34 0.30

ρR B 0.50 0.20 0.78 0.74 0.79

ρg B 0.50 0.20 0.98 0.98 0.73

ρz B 0.50 0.20 0.96 0.95 0.97

100σR IG-1 0.40 4.00 0.25 0.29 0.24

100σg IG-1 0.40 4.00 1.08 1.06 0.32

100σz IG-1 0.40 4.00 0.13 0.13 0.14

Switching Regime

ψ0π G 1.00 0.10 – 0.96 0.91

ψ1π G 2.00 0.25 – 2.13 2.30

p00 B 0.90 0.05 – 0.93 –

p11 B 0.90 0.05 – 0.96 –

α B 0.90 0.05 – – 0.96

τ N 0.00 0.50 – – �0.28

ρ U 0.00 1.00 – – 0.82

fy N 0.00 0.18 – – 0.84

fπ N 0.00 0.59 – – �1.03

fR N 0.00 0.66 – – �0.12

Log marginal likelihood �1081.51 �1051.29 �1034.51

p0.02q p0.02q p0.07qNotes: Para (1) and Para (2) refer to the means and standard deviations for Gamma (G), Normal (N), and Beta

(B) distributions; s and ν for the Inverse-Gamma Type-I (IG-1) distribution with density ppσq9σ�ν�1 exp p� νs2

2σ2 q;the lower and upper bounds of the support for the Uniform (U) distribution. The effective prior is truncated atthe boundary of the determinacy region. The numerical standard errors of log marginal likelihood estimates arereported in parentheses. The posterior means are computed using 10,000 posterior draws after thinning.

17

Page 18: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Table 2: Posterior Estimates of DSGE Models (Continued)

Fixed Regime Exogenous Switching Endogenous Switching

Parameter 90% HPD p-Value 90% HPD p-Value 90% HPD p-Value

Fixed Regime

φ r3.07, 5.20s 0.37 r1.23, 3.41s 0.82 r2.01, 3.62s 0.34

κ r0.22, 0.51s 0.79 r0.49, 1.21s 0.70 r0.12, 0.33s 0.45

ψπ r1.02, 1.29s 0.63 – – – –

ψy r0.34, 0.65s 0.71 r0.34, 0.66s 0.21 r0.32, 0.62s 0.07

rpAq r0.33, 0.62s 0.02 r0.34, 0.63s 0.40 r0.30, 0.56s 0.17

πpAq r2.20, 4.51s 0.66 r1.99, 3.18s 0.09 r2.78, 4.03s 0.07

γpQq r0.28, 0.51s 0.02 r0.22, 0.46s 0.01 r0.18, 0.44s 0.54

ρR r0.74, 0.82s 0.25 r0.68, 0.78s 0.92 r0.75, 0.82s 0.40

ρg r0.97, 0.99s 0.95 r0.98, 0.99s 0.82 r0.37, 0.97s 0.12

ρz r0.94, 0.98s 0.18 r0.93, 0.97s 0.13 r0.96, 0.99s 0.57

100σR r0.23, 0.28s 0.75 r0.25, 0.33s 0.80 r0.22, 0.27s 0.53

100σg r0.99, 1.18s 0.17 r0.98, 1.16s 0.27 r0.21, 0.52s 0.11

100σz r0.11, 0.16s 0.15 r0.11, 0.15s 0.29 r0.12, 0.17s 0.17

Switching Regime

ψ0π – – r0.85, 1.08s 0.24 r0.79, 1.04s 0.05

ψ1π – – r1.84, 2.45s 0.78 r1.98, 2.63s 0.40

p00 – – r0.89, 0.97s 0.77 – –

p11 – – r0.93, 0.99s 0.40 – –

α – – – – r0.95, 0.98s 0.04

τ – – – – r�1.01, 0.47s 0.08

ρ – – – – r0.71, 0.91s 0.74

fy – – – – r0.73, 0.94s 0.04

fπ – – – – r�1.22,�0.85s 0.31

fR – – – – r�0.22,�0.01s 0.80

Notes: The 90% highest probability density (HPD) intervals are constructed as in Chen and Shao (1999) using10,000 posterior draws after thinning. Convergence diagnostics are based on the p-values of the separated partialmeans test (assuming 15% tapered autocorrelation) that compares the sample means of the first 20% and the last50% of the MCMC draws.

1–2 as follows.

First, regarding the parameters shared by all models, allowing for regime switching does gen-

erate material impacts on some of their estimates, including the private sector parameters pφ, κq,the steady state annual inflation πpAq, as well as the government spending shock process pρg, σgq,

18

Page 19: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Figure 4: Extracted regime factor and regime-1 probability. Notes: The left and right vertical axesmeasure the filtered regime factor (blue solid line) with 90% shaded bands and the probability of beingin regime-1 (red dashed line), respectively. The black solid line delineates the threshold level. Shadedbars indicate recessions as designated by the National Bureau of Economic Research.

while others remain almost recalcitrant to that. Second, turning to the switching parameters,

introducing endogeneity into regime switching seem to produce cross-equation restrictions that

are useful for identifying policy regimes—compared to the Markov switching case, the poste-

rior mean and 90% interval of the more (less) active policy response to inflation ψ1π (ψ0

π) are

shifted upward (downward). Third, moving on to the parameters pα, τ, ρq unique to endogenous

switching, the posterior distributions suggest an even more persistent process for the regime

factor relative to its prior, a longer expected duration of the more active regime, and attribute

a significant portion (about 50%–83%) of regime changes to past monetary interventions. The

contemporaneous external shock, on the other hand, not only drives the rest of regime changes,

but also behaves like a monetary policy shock outside of the model that, as evinced by the esti-

mate of fπ, has a contractionary effect on inflation.16 Finally, a cross-model comparison of the

log marginal likelihoods indicates that the data overwhelmingly favor the endogenous switching

model over the exogenous switching or fixed regime model.17 This justifies the importance of

accounting for the endogenous feedback from historical monetary interventions to the prevailing

policy regime.

16Eric Leeper made this point to us.17Log marginal likelihoods are approximated using the modified harmonic mean estimator of Geweke (1999)

with a truncation parameter of 0.5.

19

Page 20: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Unlike the Markov switching filter of Kim (1994), our endogenous switching filter also produces

an important by-product—an extracted time series of the autoregressive regime factor wt|t as

depicted in Figure 4—that conveys richer information than its implied probability p1t|t of being

in the more active regime, most noticeably the regime strength. In particular, it identifies the

U.S. monetary policy as sluggishly fluctuating between the more active and less active regimes,

the timing and nature of which are broadly consistent with the previous empirical findings. This

pattern also aligns quite well with the narrative record of policymakers’ beliefs documented in

Romer and Romer (2004): the more active stance of the late 1950s and most of the 1960s under

chairman William McChesney Martin Jr. and of the early 1980s and beyond under Paul Volcker

and Alan Greenspan stemmed from the conviction that inflation has high costs and few benefits,

whereas the less active stance of most of the 1970s under Arthur Burns and G. William Miller

stemmed from a highly optimistic estimate of the natural rate of unemployment and a highly

pessimistic estimate of the sensitivity of inflation to economic slack.

4 Concluding Remarks

This paper aims at broadening the scope for understanding the complex interaction between

recurrent structural changes and measured economic behavior. To that end, we introduce a

threshold-type endogenous regime switching into an otherwise standard state space model, which

is general enough to include many well-known dynamic linear models as special cases. In our

approach, regime changes are, through an autoregressive latent factor, jointly driven by the

internal innovations from the transition equation and an external disturbance linked to the

measurement equation. This allows for an endogenous feedback from the behavior of underlying

economic fundamentals to the regime generating process. When regime shifts are purely driven

by the external disturbance, the model reduces to one with exogenous switching.

We develop an endogenous switching version of the Kalman filter to estimate the overall

nonlinear state space model. The filter features augmenting the transition system with the latent

factor that, in conjunction with a collapsing procedure to truncate the regime history, makes

the computation highly efficient. Monte Carlo experiment shows that our filtering algorithm

is accurate in approximating both the likelihood function and filtered state variables. We also

employ the filter to estimate a prototypical new Keynesian DSGE model with regime switching in

monetary policy, and find strong statistical support for the endogenous feedback from historical

monetary interventions to the prevailing policy regime. A natural extension of our framework is

to allow for multiple regimes and latent factors along with the development of both filtering and

smoothing algorithms, which we defer to a sequel to this paper.

20

Page 21: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Acknowledgements

The authors would like to thank Francesco Bianchi, Edward Herbst, Eric Leeper, and Joon Park

for very useful and stimulating comments. Financial support from the John Cook School of

Business summer research grant is gratefully acknowledged.

Online Appendix

This appendix presents a simplified version of Algorithm 1 that tracks only the current period

regime in each recursion. For notational ease, define the predictive and filtered marginal proba-

bilities of regime-i at period t as pit|t�1 � Ppst � i|Y1:t�1q and pit|t � Ppst � i|Y1:tq, respectively.

Then the filtering algorithm, which is again based on the augmented state space system, can be

summarized by the following steps.

Algorithm 3. (Endogenous-Switching Kalman Filter)

1. Initialization. For i � 0, 1, initialize pς i0|0, P i0|0q using the invariant distribution under

regime-i. Also set w0|Y0 �d Np0, 1{p1�α2qq so that p00|0 � Φpτa

1 � φ2q and p10|0 � 1�p00|0.Then collapse pς i0|0, P i

0|0q into

ς0|0 �1

i�0

pi0|0ςi0|0, P0|0 �

1

i�0

pi0|0�P i0|0 � pς0|0 � ς i0|0qpς0|0 � ς i0|0q1

�(A.1)

2. Recursion. For t � 1, . . . , T , the filter accepts triple inputs pςt�1|t�1, Pt�1|t�1, p0t�1|t�1q,

invokes the one-step Kalman filter to calculate the required integrals conditional on the

current period regime, and returns triple outputs pςt|t, Pt|t, p0t|tq.

(a) Forecasting. First, apply the Kalman filter forecasting step for state variables to

obtain

ς it|t�1 � rGpst � iqςt�1|t�1 (A.2)

P it|t�1 � rGpst � iqPt�1|t�1

rGpst � iq1 � �Mpst � iq�Mpst � iq1 (A.3)

Next, approximate ppwt|Y1:t�1q by the following mixture Gaussian distribution

ppwt|Y1:t�1q � p0t�1|t�1pNpς0w,t|t�1, P0w,t|t�1q � p1t�1|t�1pNpς1w,t|t�1, P

1w,t|t�1q

where pς iw,t|t�1, Piw,t|t�1q are the last and lower right corner elements of pς it|t�1, P

it|t�1q

corresponding to wt, respectively. Since the two component Gaussian distributions

21

Page 22: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

coincide, we have

p0t|t�1 � Φ�pτ � ς0w,t|t�1q{

bP 0w,t|t�1

(A.4)

and p1t|t�1 � 1 � p0t|t�1.

(b) Likelihood evaluation. Apply the Kalman filter forecasting step for observable

variables to obtain

yit|t�1 � Dpst � iq � rZpst � iqς it|t�1 (A.5)

F it|t�1 � rZpst � iqP i

t|t�1rZpst � iq1 � Σu (A.6)

Then the period-t likelihood contribution can be computed as

ppyt|Y1:t�1q � pNpyt|y0t|t�1, F0t|t�1qp0t|t�1 � pNpyt|y1t|t�1, F

1t|t�1qp1t|t�1 (A.7)

(c) Updating. First, apply the Bayes formula to update

p0t|t �pNpyt|y0t|t�1, F

0t|t�1qp0t|t�1

ppyt|Y1:t�1q (A.8)

and p1t|t � 1 � p0t|t. Next, apply the Kalman filter filtering step to obtain

ς it|t � ς it|t�1 � P it|t�1

rZpst � iq1pF it|t�1q�1pyt � yit|t�1q (A.9)

P it|t � P i

t|t�1 � P it|t�1

rZpst � iq1pF it|t�1q�1 rZpst � iqP i

t|t�1 (A.10)

To avoid a twofold increment in the number of cases to consider for the next period,

collapse pς it|t, P it|tq into

ςt|t �1

i�0

pit|tςit|t, Pt|t �

1

i�0

pit|t�P it|t � pςt|t � ς it|tqpςt|t � ς it|tq1

�(A.11)

which gives the filtered state variables.

3. Aggregation. The likelihood function is given by ppY1:T q �±T

t�1 ppyt|Y1:t�1q.

References

An, S., and F. Schorfheide (2007): “Bayesian Analysis of DSGE Models,” Econometric

Reviews, 26(2), 113–172.

22

Page 23: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

Barthelemy, J., and M. Marx (2017): “Solving endogenous regime switching models,”

Journal of Economic Dynamics and Control, 77, 1–25.

Bazzi, M., F. Blasques, S. J. Koopman, and A. Lucas (2014): “Time-Varying Transition

Probabilities for Markov Regime Switching Models,” Journal of Time Series Analysis, 38(3),

458–478.

Bianchi, F. (2013): “Regime Switches, Agents’ Beliefs, and Post-World War II U.S. Macroeco-

nomic Dynamics,” The Review of Economic Studies, 80(2), 463–490.

Bianchi, F., and C. Ilut (2017): “Monetary/Fiscal Policy Mix and Agent’s Beliefs,” Review

of Economic Dynamics, 26, 113–139.

Bianchi, F., and L. Melosi (2017): “Escaping the Great Recession,” American Economic

Review, 107(4), 1030–58.

Chang, Y., Y. Choi, and J. Y. Park (2017a): “A New Approach to Model Regime Switch-

ing,” Journal of Econometrics, 196(1), 127 – 143.

Chang, Y., and B. Kwak (2017): “U.S. Monetary-Fiscal Regime Changes in the Presence of

Endogenous Feedback in Policy Rules,” Manuscript.

Chang, Y., F. Tan, and X. Wei (2017b): “A Structural Investigation of Monetary Policy

Shifts,” Manuscript.

Chen, M.-H., and Q.-M. Shao (1999): “Monte Carlo Estimation of Bayesian Credible and

HPD Intervals,” Journal of Computational and Graphical Statistics, 8(1), 69–92.

Chen, R., and J. S. Liu (2000): “Mixture Kalman Filters,” J. R. Statist. Soc. B, 62, 493–508.

Chib, S. (1996): “Calculating Posterior Distributions and Modal Estimates in Markov Mixture

Models,” Journal of Econometrics, 75, 79–97.

Clarida, R., J. Galı, and M. Gertler (2000): “Monetary Policy Rules and Macroeconomic

Stability: Evidence and Some Theory,” Quarterly Journal of Economics, 115(1), 147–180.

Davig, T., and T. Doh (2014): “Monetary Policy Regime Shifts and Inflation Persistence,”

The Review of Economics and Statistics, 96(5), 862–875.

Davig, T., and E. M. Leeper (2006a): “Endogenous Monetary Policy Regime Change,” in

NBER International Seminar on Macroeconomics 2006, ed. by L. Reichlin, and K. D. West,

pp. 345–377. MIT Press, Cambridge, MA.

23

Page 24: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

(2006b): “Fluctuating Macro Policies and the Fiscal Theory,” in NBER Macroeconomics

Annual 2006, ed. by D. Acemoglu, K. Rogoff, and M. Woodford, vol. 21, pp. 247–298. MIT

Press, Cambridge.

DeJong, D. N., and C. Dave (2007): Structural Macroeconometrics. Princeton University

Press, Princeton, N.J.

Doucet, A., and A. M. Johansen (2011): “A tutorial on particle filtering and smoothing:

fifteen years later,” Manuscript.

Geweke, J. (1992): “Evaluating the Accuracy of Sampling-Based Approaches to Calculating

Posterior Moments,” in Bayesian Statistics 4, ed. by J. Bernando, J. Berger, A. Dawid, and

A. Smith. Clarendon Press, Oxford, UK.

(1999): “Using Simulation Methods for Bayesian Econometric Models: Inference, De-

velopment, and Communication,” Econometric Reviews, 18, 1–73.

Gordon, N., D. Salmond, and A. Smith (1993): “Novel approach to nonlinear/non-

Gaussian Bayesian state estimation,” IEEE Proceedings F, Radar and Signal Processing,

140(2), 107–113.

Hamilton, J. D. (1988): “Rational-expectations econometric analysis of changes in regime:

An investigation of the term structure of interest rates,” Journal of Economic Dynamics and

Control, 12(2), 385–423.

(1989): “A New Approach to the Economic Analysis of Nonstationary Time Series and

the Business Cycle,” Econometrica, 57(2), 357–384.

Herbst, E. P., and F. Schorfheide (2015): Bayesian Estimation of DSGE Models. Princeton

University Press.

Kalliovirta, L., M. Meitz, and P. Saikkonen (2015): “A Gaussian Mixture Autoregressive

Model for Univariate Time Series,” Journal of Time Series Analysis, 36(2), 247–266.

Kang, K. H. (2014): “Estimation of state-space models with endogenous Markov regime-

switching parameters,” The Econometrics Journal, 17(1), 56–82.

Kim, C.-J. (1994): “Dynamic Linear Models with Markov-Switching,” Journal of Econometrics,

60(1), 1 – 22.

(2004): “Markov-Switching Models with Endogenous Explanatory Variables,” Journal

of Econometrics, 122(1), 127–136.

24

Page 25: State Space Models with Endogenous ... - Indiana Universitypages.iu.edu/~wei24/research/EndoRegimeSwitchingFilter.pdfState Space Models with Endogenous Regime Switching Yoosoon Changa,

chang, tan & wei: endogenous-switching state space models

(2009): “Markov-switching models with endogenous explanatory variables II: A two-

step MLE procedure,” Journal of Econometrics, 148(1), 46–55.

Kim, C.-J., and C. R. Nelson (1999): State-Space Models with Regime Switching. MIT Press,

Cambridge, MA.

Kim, C.-J., J. Piger, and R. Startz (2008): “Estimation of Markov regime-switching re-

gression models with endogenous switching,” Journal of Econometrics, 143(2), 263–273.

Leeper, E. M. (1991): “Equilibria Under ‘Active’ and ‘Passive’ Monetary and Fiscal Policies,”

Journal of Monetary Economics, 27(1), 129–147.

Romer, C. D., and D. H. Romer (2004): “Choosing the Federal Reserve Chair: Lessons from

History,” Journal of Economic Perspectives, 18(1), 129–62.

Schorfheide, F. (2005): “Learning and Monetary Policy Shifts,” Review of Economic Dynam-

ics, 8(2), 392–419.

Sims, C. A. (2001): “Solving Linear Rational Expectations Models,” Computational Economics,

20(1), 1–20.

Sims, C. A., and T. Zha (2006): “Were There Regime Switches in US Monetary Policy?,”

American Economic Review, 96(1), 54–81.

Tanner, M. A., and W. H. Wong (1987): “The Calculation of Posterior Distributions by

Data Augmentation,” Journal of the American Statistical Association, 82(398), 528–540.

Taylor, J. B. (1993): “Discretion versus Policy Rules in Practice,” Carneige-Rochester Con-

ference Series on Public Policy, 39, 195–214.

Wei, G. C. G., and M. A. Tanner (1990): “A Monte Carlo Implementation of the EM

Algorithm and the Poor Man’s Data Augmentation Algorithms,” Journal of the American

Statistical Association, 85(411), 699–704.

X. Diebold, F., J.-H. Lee, and G. Weinbach (1994): “Regime switching with time-varying

transition probabilities,” pp. 283–302.

25