This article was updated on July 11, 2020 to reflect new changes to the statsmodels Python module and to include results from multiplicative models.

*This article was updated on July 11, 2020 to reflect new changes to the _[**_statsmodels***](https://www.statsmodels.org/stable/index.html)_ Python module and to include results from multiplicative models._

Time series decomposition is the process of separating time series data into its core components. These components include a potential trend (overall rise or fall in the mean), seasonality (a recurring cycle), and the remaining random residual. Nearly all time series that you will come across are not n aturally stationary, meaning that the mean, variance, or covariance will be time dependent. This is why data scientists must identify and separate trends and seasonality from time series data before applying a model.

You can manually remove trends by applying transformations, subtracting rolling means, and differencing to make your data stationary or you can use Python’s statsmodels library to identify trends and seasonality.

Over the past few weeks, I’ve covered a few time series topics that I will be building upon here including OHLC visualizations, time series data EDA, trend analysis, and stationarity.

All time series data can be broken down into four core components: the average value, a trend (i.e. an increasing mean), seasonality (i.e. a repeating cyclical pattern), and a residual (random noise). Trends and seasonality are not always present in time dependent data. The residual is what’s left over after trends and seasonality are removed. Time series models assume that the data is stationary and only the residual component satisfies the conditions for stationarity.

Python’s statsmodels library has a method for time series decomposition called `seasonal_decompose()`

. I utilized historical daily average closing prices of the S&P 500 index over the last five years to illustrate time series decomposition. The data was obtained from the UniBit API *(Note: In the later section I use only three years of prices due to limitations with the API)*.

Applying the ARIMA model to forecast time series dataThe notion of stationarity of a series is important for applying statistical forecasting models since.

I knew I wanted to do two things in the process of writing my bachelor’s thesis: improve my programming skills and work with time-series data prediction.

TS may look like a simple data object and easy to deal with, but the reality is that for someone new it can be a daunting task just to prepare the dataset before the actual fun stuff can begin.

Learn the Fundamental Rule of Time Series Analysis: Stationarity is an important concept in the field of time series analysis with tremendous influence on how the data is perceived and predicted.

How the number of civilian deaths by police officers impacts violent crime rates in the state. The death of George Floyd in the United States made a strong mark in the fight for human rights.