A note on implementing the Durbin and Koopman simulation smoother

Similar documents
Working Paper Series. A note on implementing the Durbin and Koopman simulation smoother. No 1867 / November Marek Jarocinski

Part I State space models

7 Day 3: Time Varying Parameter Models

Measurement Errors and the Kalman Filter: A Unified Exposition

On the Correlations of Trend-Cycle Errors

A Practical Guide to State Space Modeling

FaMIDAS: A Mixed Frequency Factor Model with MIDAS structure

Choice of Spectral Density Estimator in Ng-Perron Test: Comparative Analysis

The MIT Press Journals

BOOTSTRAP PREDICTION INTERVALS IN STATE SPACE MODELS. Alejandro Rodriguez 1 and Esther Ruiz 2

State Space Model, Official Statistics, Bayesian Statistics Introduction to Durbin s paper and related topics

SMOOTHIES: A Toolbox for the Exact Nonlinear and Non-Gaussian Kalman Smoother *

Asymptotic relations in Cournot s game

Revisiting the Synthetic Control Estimator

Time-Varying Vector Autoregressive Models with Structural Dynamic Factors

Estimates of the Sticky-Information Phillips Curve for the USA with the General to Specific Method

On the Distribution Dynamics of Human Development: Evidence from the Metropolitan Regions of Bolivia

MID-TERM EXAM ANSWERS. p t + δ t = Rp t 1 + η t (1.1)

Model-based trend-cycle decompositions. with time-varying parameters

On Linear Quadratic Approximations

Research Division Federal Reserve Bank of St. Louis Working Paper Series

State-space Model. Eduardo Rossi University of Pavia. November Rossi State-space Model Fin. Econometrics / 53

Generalized Autoregressive Score Smoothers

TREND ESTIMATION AND THE HODRICK-PRESCOTT FILTER

CENTRE FOR APPLIED MACROECONOMIC ANALYSIS

Discrete Time or Continuous Time, That is the Question: the Case of Samuelson s Multiplier-Accelerator Model

Cointegration between Trends and Their Estimators in State Space Models and Cointegrated Vector Autoregressive Models

Euro-indicators Working Group

Time-Varying Parameters

State-space Model. Eduardo Rossi University of Pavia. November Rossi State-space Model Financial Econometrics / 49

ECO 513 Fall 2008 C.Sims KALMAN FILTER. s t = As t 1 + ε t Measurement equation : y t = Hs t + ν t. u t = r t. u 0 0 t 1 + y t = [ H I ] u t.

Is there a flight to quality due to inflation uncertainty?

ivporbit:an R package to estimate the probit model with continuous endogenous regressors

Simulation Smoothing for State-Space Models: A. Computational Efficiency Analysis

Are Forecast Updates Progressive?

Online appendix to On the stability of the excess sensitivity of aggregate consumption growth in the US

Fresh perspectives on unobservable variables: Data decomposition of the Kalman smoother

Estimating Moving Average Processes with an improved version of Durbin s Method

Lecture 6a: Unit Root and ARIMA Models

Continuous Time Models to Extract a Signal in Presence of Irregular Surveys

Christopher Dougherty London School of Economics and Political Science

Generalized Impulse Response Analysis: General or Extreme?

A Test of Cointegration Rank Based Title Component Analysis.

Seasonal Adjustment of Aggregated Series using Univariate and Multivariate Basic Structural Models

On Perron s Unit Root Tests in the Presence. of an Innovation Variance Break

Marginal and Interaction Effects in Ordered Response Models

Timevarying VARs. Wouter J. Den Haan London School of Economics. c Wouter J. Den Haan

Empirical Macroeconomics

Nonstationary Time Series:

POSTERIOR MODE ESTIMATION FOR NONLINEAR AND NON-GAUSSIAN STATE SPACE MODELS

Simultaneity in the Multivariate Count Data Autoregressive Model

GMM and SMM. 1. Hansen, L Large Sample Properties of Generalized Method of Moments Estimators, Econometrica, 50, p

ARIMA Modelling and Forecasting

Using all observations when forecasting under structural breaks

Core Inflation and Trend Inflation. Appendix

Forecast Performance, Disagreement, and Heterogeneous Signal-to-Noise Ratios

Fukushima: The Failure of Predictive Models

Statistical Inference and Methods

Reliability and Risk Analysis. Time Series, Types of Trend Functions and Estimates of Trends

Empirical Macroeconomics

Equilibrium Determinacy in a Two-Tax System with Utility from Government Expenditure

A multivariate innovations state space Beveridge Nelson decomposition

Lecture 2. Business Cycle Measurement. Randall Romero Aguilar, PhD II Semestre 2017 Last updated: August 18, 2017

Comovement of East and West Stock Market Indexes

Birkbeck Working Papers in Economics & Finance

A Primer on Vector Autoregressions

Seasonal Adjustment of an Aggregate Series using Univariate and Multivariate Basic Structural Models

Dynamic probabilities of restrictions in state space models: An application to the New Keynesian Phillips Curve

Combining Macroeconomic Models for Prediction

Estimating Missing Observations in Economic Time Series

Searching for the Output Gap: Economic Variable or Statistical Illusion? Mark W. Longbrake* J. Huston McCulloch

Testing for Regime Switching in Singaporean Business Cycles

A look into the factor model black box Publication lags and the role of hard and soft data in forecasting GDP

Stationarity and cointegration tests: Comparison of Engle - Granger and Johansen methodologies

Time Series Analysis for Macroeconomics and Finance

Ekkehart Schlicht: Trend Extraction From Time Series With Structural Breaks and Missing Observations

Outline. Nature of the Problem. Nature of the Problem. Basic Econometrics in Transportation. Autocorrelation

Basic concepts and terminology: AR, MA and ARMA processes

MEXICO S INDUSTRIAL ENGINE OF GROWTH: COINTEGRATION AND CAUSALITY

Aspects of Stickiness in Understanding Inflation

WORKING PAPER SERIES CONDITIONAL FORECASTS AND SCENARIO ANALYSIS WITH VECTOR AUTOREGRESSIONS FOR LARGE CROSS-SECTIONS NO 1733 / SEPTEMBER 2014

A Mixed Frequency Steady-State Bayesian Vector Autoregression: Forecasting the Macroeconomy

State Space Model for Coincident and Leading Indexes of Economic Activity

12 TH RESEARCH MEETING OF NIPFP-DEA RESEARCH PROGRAMME

GMM estimation of spatial panels

Time Series Models and Inference. James L. Powell Department of Economics University of California, Berkeley

1 The Basic RBC Model

DSGE Model Forecasting

An Introduction to State Space Time Series Analysis. Jacques J. F. Commandeur Siem Jan Koopman

DNB W O R K ING P A P E R. Nowcasting and forecasting economic growth in the euro area using principal components. No. 415 / February 2014

Introduction to Modern Time Series Analysis

Modelling Seasonality of Gross Domestic Product in Belgium

Testing for a break in persistence under long-range dependencies. Philipp Sibbertsen and Robinson Kruse Abstract

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 26. Estimation: Regression and Least Squares

On automatic derivation of first order conditions in dynamic stochastic optimisation problems

Unobserved. Components and. Time Series. Econometrics. Edited by. Siem Jan Koopman. and Neil Shephard OXFORD UNIVERSITY PRESS

Perceived productivity and the natural rate of interest

A Forecast Rationality Test that Allows for Loss Function Asymmetries

Unit root testing based on BLUS residuals

2.5 Forecasting and Impulse Response Functions

Transcription:

MPRA Munich Personal RePEc Archive A note on implementing the Durbin and Koopman simulation smoother Marek Jarocinski European Central Bank 24. October 2014 Online at http://mpra.ub.uni-muenchen.de/59466/ MPRA Paper No. 59466, posted 24. October 2014 13:37 UTC

A note on implementing the Durbin and Koopman simulation smoother Marek Jarociński October 24, 2014 Abstract The correct implementation of the Durbin and Koopman simulation smoother is explained. A possible misunderstanding is pointed out and clarified for both the basic state space model and for its extension that allows time-varying intercepts (mean adjustments). Keywords: state space model; simulation smoother; trend output (JEL: C3; C15) 1 Introduction Consider the state space model y t = Z t α t + ε t, ε t N(0, H t ) (1a) α t+1 = T t α t + R t η t, η t N(0, Q t ), t = 1,..., T, and (1b) α 1 N(a 1, P 1 ), (1c) where y t is the observation vector, α t is the unobserved state vector, and ε t and η t are vectors of disturbances uncorrelated at all lags. The matrices Z t, H t, T t, R t, Q t, P 1 and vector a 1 are assumed to be known. For further details and illustrations of this model see, e.g., Durbin and Koopman (2012). This note explains the implementation of the Durbin and Koopman (2002) simulation smoother for this model, pointing out a possible misunderstanding. A simulation European Central Bank, Kaiserstrasse 29, 60311 Frankfurt am Main, Germany, e-mail: marek.jarocinski@ecb.int. I thank Gianni Amisano, Siem Jan Koopman and anonymous referees for very useful comments. The Matlab programs used for this note can be downloaded from runmycode.org. 1

smoother is an algorithm for drawing the states α = (α 1,..., α T ), or the disturbances (ɛ 1, η 1,..., ɛ T, η T ), from their distribution conditional on the observables y = (y 1,...y T ). The misunderstanding may arise when drawing the states. It does not arise when drawing the disturbances. 2 The correct implementation This section explains how to implement Durbin and Koopman s approach to drawing α conditional on y in the model (1a-1c). Let us call this algorithm Algorithm 2a to differentiate it from their Algorithm 2. Algorithm 2a. (modified from Durbin and Koopman (2002) Algorithm 2, p.607) Step 1. Draw α + and y + by means of recursion (1a-1b), where the recursion is initialized by a draw α 1 + N(0, P 1 ). Step 2. Construct the artificial series y = y y + and compute ˆα = E(α y ) by putting y through the Kalman filter and smoother. Step 3. Take α = ˆα + α +. α is a draw from the distribution of α conditional on y. An alternative implementation of this algorithm, which is also correct, uses (1a-1c) for the simulation of y +, α + in Step 1 but then uses the model with α 1 N(0, P 1 ) to compute the conditional expectation ˆα = E(α y ) in Step 2. The value added of this note lies in stating the above algorithm explicitly and in particular, in pointing out that a 1 needs to be reset to 0, i.e., the initial condition α 1 N(a 1, P 1 ) (1c) needs to be replaced by α 1 N(0, P 1 ) either in Step 1 or in Step 2. Durbin and Koopman (2002) state Algorithm 2, which is slower, and only suggest Algorithm 2a informally without stating it explicitly. In particular, they do not warn the reader that a 1 should be reset to 0 either in Step 1 or in Step 2, which gives rise to a possible misunderstanding that the unmodified model (1a-1c) can be used both in Step 1 and in Step 2. Two conditions have a potential to render the above misunderstanding immaterial. 1. Diffuse initialization. Durbin and Koopman (2002) prove in their Appendix 2 that the diffuse elements of α 1 + can be set equal to arbitrary quantities, hence the values of a 1 corresponding to these elements do not matter. 2. Zero mean. For the elements of α 1 + that have a zero mean the correction obviously does not matter, since the corresponding values of a 1 equal 0 anyway. 2

Therefore, the misunderstanding is immaterial when all the elements of α 1 are either diffuse or have a zero mean. In a model with intercepts another modification of Algorithm 2 is needed. Suppose the model is given by (1c), y t = d t + Z t α t + ε t, ε t N(0, H t ) and (2a) α t+1 = c t + T t α t + R t η t, η t N(0, Q t ), (2b) where d t and c t are intercepts that are known and may change over time. The remaining quantities are defined under equations (1a-1c). Algorithm 2a can also be used with this model, but the intercepts d t and c t should be reset to 0 for all t either in Step 1 or in Step 2. 3 A formal justification I now provide a formal justification of Algorithm 2a. This algorithm assumes ( ) (( α N y µ α µ y ), ( Σ αα Σ yy )) and ( α + y + ) (( ) ( 0 Σ αα N, 0 Σ yy )), (3) where the unconditional moments µ α, µ y, Σ αα, and Σ yy are functions of Z t, H t, T t, R t, Q t, P 1, a 1 (c t, d t if applicable) implied by (1a-1c) or by (2a,2b,1c). Note, in particular, that resetting of µ α and µ y to 0 is achieved by resetting a 1 and, if applicable, c t and d t for all t to 0. A draw α is generated as α = E(α y ) + α + = µ α + Σ 1 yy (y y + µ y ) + α +. The first and second moments of α conditional on y are E( α y) = µ α + Σ 1 yy (y µ y ) = E(α y) V ( α y) = Σ 1 yy Σ yy Σ 1 yy Σ αy 2 Σ 1 yy Σ αy + Σ αα = Σ αα Σ 1 yy Σ αy = V (α y). Hence, the first and second moments of α are correct and α is indeed a draw from p(α y). Note, however, that setting the mean of (α +, y + ) to (µ α, µ y ) due to the discussed misunderstanding would have changed the value of E( α y) and hence would have produced a draw from an incorrect density. and 3

4 Numerical examples I illustrate the effect of the possible misunderstanding using two numerical examples from the literature. 4.1 Nile data The first example is the well-known local level model of the Nile data (a series of readings of the annual flow volume at Aswan from 1871 to 1970). Durbin and Koopman (2012), and others fit the following model to these data: y t = α t + ε t, ε t N(0, 15099) and (4a) α t+1 = α t + η t, η t N(0, 1469.1), (4b) where y is the observed flow volume and α is its unobserved trend. Table 1 reports the means and standard deviations of 10,000 draws of the trend α generated with several setups. Initialization 1 assumes, for illustrative purposes, that α 1 comes from the Gaussian distribution centered at the first observation y 1 with the variance equal to the variance of the deviations of α from y throughout the sample, i.e. 15099. I generate 10,000 draws using Algorithm 2a and then I generate 10,000 draws with an incorrect variation of this algorithm, where I do not reset a 1 to 0 neither in Step 1 nor in Step 2. It is clear from Table 1 that the misunderstanding seriously distorts the simulation smoother: the mean of the trend in the first period, α 1, is 1114 with the correct algorithm (column 1) and 1350 with the incorrect variation (column 2). After 50 periods the initialization matters less and the means of the trend in period 50, α 50, obtained with Algorithm 2a and its incorrect variation are similar, 834 vs 835. Then I use the diffuse initialization for α and generate 10,000 draws first with Algorithm 2a and then with its incorrect variation. When the initialization is diffuse I obtain the same means and standard deviations of α with both implementations of Algorithm 2a, so I only report them once (column 3). To summarize, this numerical example illustrates that the misunderstanding can distort the results significantly 1) for the draws of states in the beginning of the sample and 2) when the initialization of the state is non-diffuse. 4.2 Trend of real GNP The second example uses the model from Watson (1986). Watson fits the following model for the real Gross National Product (GNP) of the United States, y t, observed quarterly 4

Table 1: Trend flow volume in the Nile model. Mean, standard deviation in parenthesis. Initialization 1 (non-diffuse) Algorithm 2a No resetting of a 1 Diffuse initialization τ 1 1112 (57) 1350 (57) 1111 (64) τ 50 834 (48) 835 (49) 835 (48) from 1949 to 1984. y t = τ t + ς t, (5a) τ t = 0.008 + τ t 1 + η τ t, η τ t N(0, 0.0057 2 ) and (5b) ς t = 1.501ς t 1 0.577ς t 2 + η ς t, η ς t N(0, 0.0076 2 ), (5c) where τ t is a trend and ς t is a cycle, both unobservable. Table 2 reports the mean and standard deviation of 10,000 draws of trend GNP, generated with several setups. Initialization 1 assumes that ς 1 comes from the ergodic distribution of ς t and that τ 1 is centered at the last value of GNP before the start of the sample, with the ergodic variance of ς t. This is a natural assumption exploiting the stationarity of ς t. I generate 10,000 draws using Algorithm 2a and then I generate 10,000 draws with an incorrect variation of this algorithm, where I do not reset a 1 and c t to 0 neither in Step 1 nor in Step 2. It is clear from Table 2 that the misunderstanding seriously distorts the simulation smoother: the mean of the trend GNP in the first period, τ 1, is 6.24 with the correct algorithm (column 1) and 6.14 with the incorrect variation (column 2). After 50 quarters the initialization matters less and the means of the trend GNP in period 50, τ 50, obtained with Algorithm 2a and its incorrect variation are the similar, 6.66 vs 6.65. Next, I use the diffuse initialization of τ and ς. The mean of τ 1 is 6.28 with Algorithm 2a (column 3) and 6.09 with its incorrect variation (column 4). The misunderstanding matters here even with the diffuse initialization of τ and ς, because when model (5a-5c) is cast in form (1a-1b) the constant term of equation (5b) is a state with a non-zero and non-diffuse initialization and the failure to reset a 1 to 0 distorts the simulation smoother. Equivalently, when model (5a-5c) is cast in form (2a-2b) all the states are zero-mean or diffuse, but the failure to reset c t to zero distorts the simulation smoother and yields the same numerical results. Again, after 50 quarters the trend GNP is similar with and without the misunderstanding. 5

Table 2: Trend GNP in Watson s model based on simulation smoothers. Mean, standard deviation in parenthesis. Initialization 1 (non-diffuse) Diffuse initialization Algorithm 2a No resetting of a 1, c t Algorithm 2a No resetting of a 1, c t τ 1 6.24 (0.02) 6.14 (0.02) 6.28 (0.03) 6.09 (0.03) τ 50 6.66 (0.02) 6.65 (0.02) 6.66 (0.02) 6.65 (0.02) 5 Conclusion This note explains the implementation of the Durbin and Koopman algorithm for drawing the states conditionally on the observables in a state space model, pointing out a possible misunderstanding. The misunderstanding matters when the initial state vector is not all zero-mean or diffuse, or when a nonzero intercept is present, and leads to incorrect draws of the states, especially in the beginning of a sample. By clarifying the possible misunderstanding, this note hopefully encourages an even wider use of the Durbin and Koopman algorithm by practitioners. References Durbin, J. and Koopman, S. J. (2002). A simple and efficient simulation smoother for state space time series analysis. Biometrika, 89(3):603 615. Durbin, J. and Koopman, S. J. (2012). Time Series Analysis by State Space Methods: Second Edition. Oxford Statistical Science Series. OUP Oxford. Watson, M. W. (1986). Univariate detrending methods with stochastic trends. Journal of Monetary Economics, 18(1):49 75. 6