Time Series Analysis using Unobserved Components Model in Python

Time Series Analysis using Unobserved Components Model in Python

Hey there statisticians and Time Series fanatics! Here’s my take on the Unobserved Components Model. Happy reading!

What is UCM?

Unobserved Components Model (UCM) (Harvey (1989)) performs a time series decomposition into components such as trend, seasonal, cycle, and the regression effects due to predictor series.

What to expect from this article?

In an influential article, Harvey and Jaeger (1993) described the use of unobserved components models (also known as “structural time series models”) to derive stylized facts of the business cycle. In particular, they make the argument that these goals are often better met using the unobserved components approach rather than the popular Hodrick-Prescott filter or Box-Jenkins ARIMA modeling techniques. Taking inspiration from Harvey and Jaeger I consider the following time series:

  • US real GNP, “output”, (GNPC96)
  • US GNP implicit price deflator, “prices”, (GNPDEF)

The time frame in the original paper varied across series but was broadly 1954–1989. Below I use data from the period 1970–2020 for all series. Although the unobserved components approach allows isolating a seasonal component within the model, the series considered in the paper, and here, are already seasonally adjusted. All data series considered here are taken from the Federal Reserve Economic Data (FRED). Conveniently, the Python library Pandas can download data from FRED directly.

You can expect a deep dive into the theory behind UCM as well as the hands-on implementation of UCM on real-world data.

PROCEED AT CAUTION! (p.s.-It’s not that difficult, believe in yourself)


Getting Data

No alt text provided for this image

This is how the data looks like:

No alt text provided for this image
No alt text provided for this image

ABOUT THE MODEL-

Alright, this is what you’re here for!

Now we know: Response Time Series = Superposition of components such as Trend, Seasons, Cycles, and Regression effects…

Each component in the model captures some important features of the series dynamics. Components in the model have their probabilistic models. The probabilistic component models include meaningful deterministic patterns as special cases.

This is what the generalized model looks like:

No alt text provided for this image

Components-

Trend-

The trend component is a dynamic extension of a regression model that includes an intercept and linear time-trend.

No alt text provided for this image

where the level is a generalization of the intercept term that can dynamically vary across time, and the trend is a generalization of the time-trend such that the slope can dynamically vary across time. For both elements (level and trend), we can consider models in which:

The element is included vs excluded (if the trend is included, there must also be a level included). The element is deterministic vs stochastic (i.e. whether or not the variance on the error term is confined to be zero or not)

Trends are loosely defined as the natural tendency of the series to increase or decrease or remain constant over a period of time in absence of any other influencing variable.UCM can model trend in two ways; first being the random walk model implying that trend remains roughly constant over the time period of the series, and the second being locally linear trend having an upward or downward slope.

To continue reading, please visit:

Lakshay Malhotra

Data Science | Credit Risk | Risk Analytics | Portfolio Management |

4y

Helpful! This will

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics