Monday, August 12, 2024

Estimation of Local Linear Trend via Kalman Filter

Authors and guest post by Eren Ocakverdi

This blog piece intends to introduce a new add-in (i.e. LOCALLINEAR) that estimates local linear trends via Kalman filter.

Table of Contents

  1. Introduction
  2. Local Linear Trend model
  3. Application to credit card expenditure data
  4. Files
  5. References

Introduction

Filtering trend component is a useful way of summarizing time series data as it allows one to capture and focus on the important characteristics that truly matter. However, filtering methods may lead to loss of information and therefore come at a price. Nevertheless, Linear State Space Models (LSSM) offer a practical approach to extract the unobserved trend component of an observed variable.



Local Linear Trend Model

Add-in implements the following framework:

\begin{align*} y_{t} &= \mu_{t} + \sum_{i = 1}^{m}{b_{i} x_{it}} + e_{t}, \quad e_t \sim IID(0, \sigma_{e}^{2})\\ \mu_{t} &= \mu_{t - 1} + \Delta\mu_{t - 1} + \epsilon_{t}, \quad \epsilon_t \sim IID(0, \sigma_{\epsilon}^{2})\\ \Delta\mu_{t} &= \Delta\mu_{t - 1} + v_{t}, \quad v_t \sim IID(0, \sigma_{v}^{2}) \end{align*} The model above is very flexible, which can make it difficult to differentiate unobserved trend values from the actual levels in practice. In such cases, restricting the variance of trend equation to zero (i.e. $ \sigma_{\epsilon}^{2} = 0 $) may help obtain a smooth(er) stochastic trend. It is also possible to impose an exogenous penalty parameter (i.e. $ \lambda = \frac{1}{q} $) at the outset and control the smoothness of trend (i.e. $ \sigma_{v}^{2} = \frac{\sigma_{e}^{2}}{\lambda} $) as in the sense of Hodrick-Prescott filter.

Any kind of explanatory variable(s) or intervention effect(s) can be added to the model through regressors in the signal equation.



Application to weekly credit card expenditure data

High(er) frequency financial variables are generally noisy due to a number of reasons, most of which cannot be controlled or identified even after the fact. Filtering out the noise component arising naturally from changing market conditions period-to-period may provide us with a clear(er) picture of underlying trend without much loss of critical information. In this exercise, Turkish weekly credit card expenditure data is used (see Figure 1).


Figure 1: Total credit card expenditures (in local currency, billions)

Credit card expenditure data does not look smooth in the levels, but it becomes even more erratic when we look at the weekly change (see Figure 2).


Figure 2: Weekly change of credit card expenditures (%)

Frequent and severe spikes in the data make it difficult to read the underlying dynamics. Stochastic trend estimation might help filter out such fluctuations in the data.

To estimate local linear trend model, we can use the add-in (see Figure 3).


Figure 3: Add-in GUI

Taking logarithm is useful to mitigate the scale effects normally present in such nominal variables. Estimation of smooth stochastic trend may also be helpful in further reducing the noise in the latent component. Finally, we might want to take into account the seasonality and see if spending patterns change with respect to calendar month (see Figure 4).


Figure 4: Comparison of weekly changes in actual level and in estimates of trend (%)

Loss of momentum in credit card expenditures becomes more visible after filtering out the noise as well as controlling seasonal effects.




Files




References

  1. Durbin, J. and Koopman, S. J. (2001), Time Series Analysis by State Space Methods, 2nd ed.", Oxford University Press.

No comments:

Post a Comment