The Complete Guide to Time Series Models
Tags: beginners, datascience, data
Published: 2023-10-20 12:33:37

A time series model is a set of data points ordered in time, where time is the independent variable. These models are used to analyze and forecast the future.
A time series is a series of data points ordered in time. 
Time series analysis is about inferring what has happened to a series of data points in the past and attempting to predict what will happen to it the future. 
Characteristics of time series  models:

- Stationary
- Seasonality
- Autocorrelation

We can use time series models to predict possible forecasts.

**Characteristics of Time Series Model**

**Autocorrelation**

Autocorrelation is the degree of correlation of the same variables between two successive time intervals. It measures how the lagged version of the value of a variable is related to the original version of it in a time series. For time-series, the autocorrelation is the correlation of that time series at two different points in time ,also known as lags. Meaning we are measuring the time series against some lagged version of itself.

**Seasonality**
 Time series data may contain seasonal variation. Seasonal variation, or seasonality, are cycles that repeat regularly over time. A repeating pattern within each year is known as seasonal variation, i.e. repeating patterns within any fixed period.

**Stationarity**
A stationary time series is one whose properties do not depend on the time at which the series is observed. It does not mean that the series does not change over time, just that the way it changes does not itself change over time. Therefore, time series with trends, or with seasonality, are not stationary ,the trend and seasonality will affect the value of the time series at different times.

**Testing Whether a Process is Stationary**

**Visualizations**

The most basic methods for stationarity detection rely on plotting the data and visually checking for trend and seasonal components. Trying to determine whether a stationary process generated a time series just by looking at its plot is tasking. However, there are some basic properties of non-stationary data that we can look for.

**Statistical Tests**
One statistical tests which we will be going into is:

**Augmented Dickey-Fuller (ADF) Test**
Statistical tests make strong assumptions about the available data. They can  be used to inform whether a null hypothesis can be rejected or fail to be rejected.

They provide confirmation that the time series is stationary or non-stationary. It evaluates the null hypothesis to determine if a unit root is present. If the equation returns p>0, then the process is not stationary. If p=0, then the process is considered stationary.

**How to Build Time Series Models**

The most popular ways to model time series are:

- Moving average.
- Exponential smoothing.
- Double exponential smoothing.
- Triple exponential smoothing.
- Seasonal autoregressive integrated moving average (SARIMA.)

**Moving Averages**

Is a common approach for modeling univariate time series. The moving-average model specifies that the output variable is cross-correlated with a non-identical to itself random-variable.

**Exponential Smoothing**
Is a method for forecasting univariate time series data. It is based on the principle that a prediction is a weighted linear sum of past observations or lags. The Exponential Smoothing time series method works by assigning exponentially decreasing weights for past observations. Less importance is given to observations as we move further from the present.

**Double exponential Smoothing**
Double exponential smoothing is used when there is a trend in the time series.
Also known as Holt's trend model or second-order exponential smoothing. Double exponential smoothing is used in time-series forecasting when the data has a linear trend but no seasonal pattern. The basic idea here is to introduce a term that can consider the possibility of the series exhibiting some trend.

**Triple Exponential Smoothing**
Triple exponential smoothing is used when there is trend
in the data along with seasonal variations. This method is based on three smoothing equations: stationary component, trend, and seasonal. Both seasonal and trend can be additive or multiplicative.

**Seasonal Autoregressive Integrated Moving Average Model (SARIMA)**
 SARIMA is an effective and popular time series model for predicting future values of time series data. It is a useful tool for predicting recurring trends in time series data since it is specifically developed to capture seasonality in time series data. They are a combination of autoregressive (AR) models, moving average (MA) models, and differencing.

**Application of Time Series Models**

**Determining patterns**

 Helps organizations understand the underlying causes of trends or systemic patterns over time. Using data visualizations, business users can see seasonal trends and dig deeper into why these trends occur.

**Forecasting and future trends**

The ultimate goal of time series forecasting is to utilize historical data in order to understand future outcomes. The many uses of this include making better strategic business decisions, anticipating shifting trends and pivoting approaches based on that.

**Detecting anomalies**

Anomaly detection in time series has become an increasingly vital task, with applications such as fraud detection and intrusion monitoring. Tackling this problem requires an array of approaches, including statistical analysis, machine learning, and deep learning.

**Examples of Forecasting with time series models**

**Healthcare**
Time series models can be used to monitor the spread of diseases by observing how many people transmit a disease and how many people die after being infected.

**Agriculture**

Time series models take into account seasonal temperatures, the number of rainy days each month and other variables over the course of years, allowing agricultural workers to assess environmental conditions and ensure a successful harvest.

**Finance**
Financial analysts can leverage time series models to record sales numbers for each month and predict potential stock market behavior.
**Retail**
Retailers may apply time series models to study how other companies’ prices and the number of customer purchases change over time, helping them optimize prices.