DEV Community

Cover image for The Complete Guide to Time Series Models
Vee
Vee

Posted on

The Complete Guide to Time Series Models

Have you ever wondered how meteorologists are able to predict future weather, or how businesses predict future trends, and easily detect changes in the market? Those are just a few eye openers of how Time Series works in various aspects of our daily lives. In this guide, we are going to get an understanding of Time series models work and the way they apply in our daily life.

Understanding Time series

According to Wikipedia, a time series is a series of data points indexed in time order. A time series model is a type of machine learning model used to analyze and forecast the future based on verified previous data observed at regular intervals (Engineering Statistics Handbook, 2010). In this model, time is usually the independent variable.

Time series models use non-stationary data. Non-stationary data is data that keeps fluctuating with time. The data is analyzed to give insights on different trends over time. This is what makes time series models part of predictive analytics

Characteristics of time series models

  • Seasonality: Refers to patterns that occur regularly ( weekly, quarterly, monthly or annually) in the data due to various seasonal factors. For example, ice cream sales are higher during summer and low during winter. The figure below is an illustration of seasonality

seasonality

Image: Marco Peixeiro

  • Stationarity: This is the state of statistical properties of a time series not changing over time. This means a constant mean, variance and covariance is independent of time. Stationarity is very crucial as it influences how data is perceived and predicted. The following diagram shows an example of a stationary process:

Stationarity

Image: Marco Peixeiro

  • Autocorrelation: This is the degree of similarity between a given time series and a lagged version of itself over a certain period of time. It measures the relationship between a variable's current value and its past values. An autocorrelation of +1 represents a perfect positive correlation, while an autocorrelation of -1 represents a perfect negative correlation. For instance, in businesses, autocorrelation can be used to evaluate how past prices are likely to influence future prices.

Autocorrelation

Image: Marco Peixeiro

Types of Time series analysis

There are various types of time series analysis used for different purposes. They include:

  1. Forecasting: It is used to predict the future. It utilizes past data as a model for future data to predict future events.

  2. Explanative: It strives to understand the data and the relationships within it including cause and effect.

  3. Curve fitting: It plots the data along a curve to examine the relationships between variables in data.

  4. Segmentation: It attempts to understand the underlying properties of the source information by splitting the data into segments.

  5. Classification: It identifies and assigns categories to the data.

Time series models

Time series models are classified into three broad categories:

Combinations of these three models brings forth autoregressive moving average (ARMA) and autoregressive integrated moving average (ARIMA) models.

Autoregressive moving average (ARMA) model

The ARMA model is a regression model where the dependent variable is a linear function of past values of both the dependent variable and the error term. The order of an ARMA model is represented by ‘p’ for the autoregressive part and ‘q’ for the moving average part. For example, if p=0 and q=0, then it means that we are predicting time-step (t) based on time-step (t) only. If p=n and q=m, then we are predicting time-step (t) based on n past time-steps of the dependent/response variable and m past time-steps of the error term.

Autoregressive integrated moving average (ARIMA) model
The autoregressive integrated moving average (ARIMA) model is a generalization of the ARMA model. The ARIMA model is a regression model in which the dependent variable is a linear function of past values of both the dependent variable and the error term, where the error term has been differentiated ‘d’ times. The model's goal is to predict future securities or financial market moves by examining the differences between values in the series instead of through actual values.

Seasonal autoregressive integrated moving average (SARIMA) model
SARIMA is a type of time-series forecasting model that takes into account both seasonality and autocorrelation. SARIMA models are based on a combination of differencing I(d), autoregression model AR(p), moving average model MA(q) and seasonality S(P, D, Q, s), where s is simply the season’s length.

SARIMA Model

Image: Utkarsh Soni,Helical IT Solutions(2023)

SARIMA models are generally considered to be more accurate than other types of time-series forecasting models, such as ARIMA models. SARIMA models are also relatively easy to interpret and use. The SARIMA model can be used to forecast demand for a product or service over the course of a year, forecasting stock prices and weather patterns.

Applications of time series models

Finance − It includes sales forecasting, inventory analysis, stock market analysis, price estimation.

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.

Meteorology − Time series models can be used in temperature estimation, climate change, seasonal shift recognition, and weather forecasting.

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.

Conclusion

In this article, you have had an introduction to the fascinating world of time series models. Understanding time series data, its components, and the models used to analyze it is a crucial skill in today's data-driven world. For further study, consider the following resources:
The complete guide to Time series models

Different types of Time-series Forecasting Models

Time series analysis

Top comments (0)