The Complete Guide to Time Series Model
Published: 2023-10-26 06:15:44

**Time series analysis** comprises methods for analyzing time series data in order to extract meaningful statistics and other characteristics of the data while **time series forecasting** is the use of a model to predict future values based on previously observed values.

Combining time series analysis and time series forecasting we derive **time series model** which refers to data points ordered in time used in forecasting the future.

## Forecasting Models
The tool used in conducting time series model is referred to as ARIMA an acronym for Auto Regressive Integrated Moving Average.

_**How ARIMA is applied**_
It is specified by three order parameters: **p**, **d**, **q**.
_**P**_ refers to the number of autoregressive terms (**AR**)
**_d_** refers to how many non – seasonal differences are needed to achieve stationarity (**I**)
**_q_** refers to the number of lagged forecast errors in the prediction equation (**MA**)

## Stationarity of Time Series

The stationarity of time series depends on:
•	Mean
•	Variance
•	Co-variance


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/icov4cvzwoef5f3l7prq.jpg)

The variance of the series should not be a function of time.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6e0dqhrai25n4xc52vm5.jpg)

The covariance of the **i th** term and the (**i  + m**) th term should not be a function of time.


_**When the values are constant over a period of time.**_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4mk8d59eboielffo8xv.jpg)

## **Components Affecting Time Series**
**_Trend_**
This is the increase or decrease in the series over a period of time. It persists over a long period of time. 

_Example: Population growth over the years can be seen as an upward trend._

**_Seasonality_**
Seasonality refers to the regular pattern of up and down fluctuations. It is a short –term variation occurring due to seasonal factors.

_Example: sale of ice-cream increases on summer._

**_Cyclicity_**
This is a medium – term variation caused by circumstances, which repeat in irregular intervals.

_Example: 5 years of economic growth, followed by 2 years of economic recession, followed by 7 years of economic growth followed by 1 year of economic recession._

**_Irregularity_**
This refers to the variations that occur due to unpredictable factors and also do not repeat in particular patterns.

_Example: Variations caused by incidents like earthquakes, war, floods and other variations that have unpredictable factors._

**

## Moving Average
**
The moving average model is probably the most simple approach to time series modeling. This model simply states that the next observation is the mean of all past observations.

_**Exponential Smoothing**_
Exponential smoothing uses similar logic to moving average, but this time, a different decreasing weight is assigned to each observation. In other words, less importance is given to observations as we move further from the present.
Mathematically, exponential smoothing is expressed as: 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cgp3onov1urznaub99jx.jpg)

Alpha is a smoothing factor that takes values between zero and one. It determines how fast the weight decreases for previous observations.

**_Double Exponential Smoothing_**
Double exponential smoothing is used when there is a trend in the time series. In that case, we use this technique, which is simply a recursive use of exponential smoothing twice.
Mathematically:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50yf0yfat8e6ep2ihcta.jpg)

Here, beta is the trend smoothing factor, and it takes values between zero and one.


**_Triple Exponential Smoothing_**
This method extends double exponential smoothing by adding a seasonal smoothing factor. Of course, this is useful if you notice seasonality in your time series.
Mathematically, triple exponential smoothing is expressed as:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m04u8x2xgdhqndbbtey7.jpg)

## Why Time Series Models?
There are a number of reasons why businesses and organizations through their respective Data personal conduct Time series analysis. The following are some of the applications of the Time Series Modeling.

**_Forecasting Future Trends _**
Based on previous data collected through time series models, businesses can predict how future trends may develop to protect their financial resources, explore new markets, restock inventory and perform other tasks. 

**_Detecting Anomalies_**
Time series models also allow organizations to more easily spot data shifts that may signal unusual behavior or changes in the market.

_**Determining Patterns**_
Businesses that rely on seasonal sales, monthly online traffic spikes and other repetitive behavior can establish expectations based on time series models, gauging their overall health and performance.

## 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.
 

**_Cybersecurity_**
IT and cybersecurity teams can develop patterns in user behavior with time series models, allowing them to be aware of when behavior doesn’t align with normal trends.
 
_**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.