Every one of us is familiar with Time, yet it is hard to define and understand it. Time is not something we can see, touch, or taste, but we can measure its passage. Physicists define time as the progression of events from the past to the present into the future. Whenever data or observations recorded at regular time intervals, we are looking at Time Series data. In this blog, I will try to explain some of the basics of the Time Series and how it can be used for forecasting or in the prediction of the future.
Table of Contents
What is Time Series?
Time Series Real-world examples
Components of Time Series
Classification of Time Series data
Mathematical model for Time Series Analysis
What is Time Series?
A time series is nothing but a set of observations taken at the specified time, usually at regular intervals. Time series is looking at data over time to predict or forecast what will happen in the future, based on patterns or trends that occurred from the previous time periods.
In machine learning, a series of statistical observations taken at a specified time is called a Time Series. The statistical set of data is then analyzed and used to predict the future.
What makes the Time Series model different from other types of predictive models, is that the prediction is based on a given time, looking at a sequence of observations over time.
We can always guess by looking at a trend on a graph that the trend will probably continue, but a Time Series forecast can give us a better-estimated figure for how long it could continue with the same trend.
Time Series Real-world examples
Time series is everywhere. The most common, basic example of a time series is seasonal sales revenue. During the holiday or festival season, the sales go up, and during the off-seasons, sales go down each year.
Another interesting example is, say we have a sensor device recording the number of vehicles that cross an intersection every 30 minutes. We can then use these numbers to predict the traffic at this particular intersection in the next 30 minutes. If the traffic is going to spike up, then the trip planning app could re-route the drivers to avoid delays and distribute the traffic load to other routes.
Other examples of time series in real-world are:
Stock price prediction
Weather forecasts
Population prediction using birth and death rate
Detection of anomalies in the field of Cyber Security
Sales/Production forecasting
Study of telephone/online traffic
Medical devices measuring and visualizing the vitals
and many more…..
Components of Time Series
Time series can be decomposed into four components, each expressing a particular aspect of the movement of the values of the time series.
They are: Trend, Seasonality, Cycles, Irregularities
Seasonal and Cyclic Variations are short-term fluctuations, whereas the trend is long-term movements and irregularities are unknowns.
1. Trend - this refers to the overall long term direction of the series
The trend shows the general tendency of the data to increase or decrease during a long period of time. It can either be upward, downward or stable depending on the tendency. The population, agricultural production, items manufactured, number of births and deaths, are some of the examples showing some kind of tendencies of movement.
2. Seasonality - this refers to the repeated behavior of data which occurs at regular intervals
The seasonality tends to repeat itself over a certain period of time. They almost have the same pattern during a period of 12 months. This variation will be present in a time series if the data are recorded hourly, daily, weekly, quarterly, or monthly.
Due to natural conditions like climatic changes or seasons, we can get this type of variations in time series. Few examples of this: production of fruits/crops depend on seasons, the sale of umbrellas and raincoats will be high in the rainy season, and the sale of electric fans and A.C. shoots up in summer seasons.
The effect of man-made conventions such as some festivals, holiday season recurs themselves year after year. During such periods, the sales and prices go up.
3. Cycles — this occurs when a series follows an up-and-down pattern that is not seasonal
The series is likely cyclical if the variations are based on previous values of the series rather than directly on time. For example, when the value of stocks goes up, it gives confidence in the market, so more people invest making prices go up, and vice versa, therefore stocks show a cyclical pattern.
4. Irregularities — this refers to strange dips or jumps in a series.
These variations are unforeseen, uncontrollable, unpredictable, and are erratic. Some of the examples are earthquakes, wars, floods, famines, and any other disasters. Currently, the pandemic is also a very good example of this variation. During this pandemic, many businesses either incurred a huge loss or made more profit. For example, online sales have really gone up whereas local shop owners faced a huge loss because of a decrease in sales.
Some of the examples of Time Series that I mentioned earlier are represented as graphs for better understanding.
Classification of Time Series data
The Time Series data can be classified into two types:
Data or measurements captured at regular intervals - Metrics
Data or measurements captured at irregular intervals - Events
In the examples shown above, all four measurements are captured at regular intervals depicting metrics.
Time Series data can be captured whenever an event happens regardless of the time interval. Event Logs and traces used for bug fixing and resolve issues are good examples of events.
Linear and nonlinear Time Series data
If we plot the time series data on a graph in accordance with time t, the pattern of the data clustering shows the type of trend. If the set of data cluster around a straight line, then the trend is linear otherwise it is non-linear (Curvilinear).
Univariate and Multivariate Time Series
The Time Series that has a single value at each time step is called Univariate Time Series. Eg, every day in the weather forecast.
The Time Series that has multiple values at each time step is called Multivariate Time Series. Eg, the latitude and longitude of the path of a car
Stationary and Non-stationary Time Series
If the behavior of the Time Series doesn’t change over time, then it is called stationary Time Series. These types of time series are really well suited for predictions. The reverse, which is non-stationary data is that that doesn’t have a constant behavior. The trend and seasonality sudden changes make it very difficult to predict. In such cases, we will have to train for a limited period of time.
Mathematical Model for Time Series Analysis
Mathematically, a time series is given as
Here, y is the value of the variable under study at time t. If the variable is observed at various time period t1, t2, t3, …, tn, then the time series is
Additive Model for Time Series Analysis
If yt is the time series value at time t and Ut, Vt, Xt, and Zt are the trend value, seasonal, cyclic, and random fluctuations at time t respectively, then according to the Additive Model, a time series can be expressed as
This model assumes that all four components of the time series act independently of each other.
Multiplicative Model for Time Series Analysis
The multiplicative model assumes that the various components in a time series operate proportionately to each other. According to this model
Mixed models
Different assumptions lead to different combinations of additive and multiplicative models as shown below:
Some of the terms that are used in the Time Series analysis are:
Noise - a complete set of random values that are not predictable and this type of data will not be of much use in prediction.
Innovations - the spikes in a Time Series that are unpredictable. In other words, they cannot be predicted based on past values.
Autocorrelation - is a type of serial dependence. Specifically, autocorrelation is when a time series is linearly related to a lagged version of itself.
To conclude, Time Series analysis is more useful because it uses past data to predict the future, which can be used in various different fields for planning and execution. I have explained the basics of the Time Series in this blog and hope this will be useful for people to understand it better.
Happy Analyzing!