Time Series Intro
Time Series Intro
• Is your company making more money during the summer months or at the beginning of the fiscal year? Does analyzing weather data to see if
winter storms caused any loss in revenue? How many customers come into the store every day? How much revenue has the business generated
over the last few weeks? What is the probability of rain tomorrow? Predicting the future sales of a company by analyzing its past performance.
climate cycles and fluctuations in the economy, as well as volcanic eruptions and earthquakes, are examples of natural systems,
whose behavior can best be studied using time series analysis.
• Predicting the state of the economy of a country by analyzing various factors affecting it.
It could be helpful in planning future actions, saving money, and ensuring quality. – Such and more such like queries can be answered through time
series .
A Time Series is a set of numerical observations, each one being recorded at a specific time. A time series is a sequence of observations that are
arranged according to the time of their outcome. The sequence of data points indexed or based on time and recorded in successive order is
called time-series data points.
Time series is basically sequentially ordered data indexed over time (the independent variable), the dependent variable might be
• Stock market data
• Sales data of companies
• Data from the sensors of smart devices
• The measure of electrical energy generated in the powerhouse.
To decompose the time series and look for some basic components :
• Trend - useful in predicting future movements. Over a long period of time, the trend shows whether the data tends to increase or decrease. An
average, long-term, smooth tendency. Not all increases or decreases have to occur simultaneously. Different sections of time show varying
tendencies in terms of trends that are increasing, decreasing, or stable. There must, however, be an overall upward, downward, or stable trend.
• Seasonality - the variation in some variable due to some predetermined patterns in its behavior. This definition can be used for any type of
time series including individual commodity price quotes, interest rates, exchange rates, stock prices, and so on.
• In many applications, seasonal components can be represented by simple regression equations. This approach is sometimes referred to as a
“seasonalized regression” or a “bimodal regression”. The repetitive patterns at certain times of year are called seasonality. For example, sales
of cakes will peak every December in the US because of Christmas.
• cyclic behavior - the part of the movement in the variable which can be explained by other cyclical movements in the economy.
• It is also called the long-period (LP) effect or boom-bust process. For example, during recessions, business cycles are usually characterized by
slower growth rates than before the recession started.
• irregular fluctuations - the part of the movement in the variable which cannot be explained by cyclical movements in the economy.
• Residual: The data remaining after removing the above three is called Residual.
Saurav Banerjee 1
Assume that you are having the time-series data of an airline passenger company, if you do an initial analysis on the data, you can find that in
each year during particular periods of time, a particular pattern may be found (a seasonal pattern). Further investigating we may find that it was
because vacations were happening in those months because of which families were travelling.
•An increase/decrease in the passenger count(upward/downward trend), which may be related to some other factors that were affecting the
airlines at that time.
There are two approaches to time series analysis: • Time Domain Approach Given the observed time series, how does one guess future values?
• Frequency Domain Approach (also known as the Spectral or Fourier analysis of time series)
Stationary And Non-stationary Time Series?
•The time series which has constant mean and variance is called stationary time series. It is recommended to have the stationary time series for
better analysis. The predictions on non-stationary series may give wrong values.
•To check whether a series is stationary or not, there are several tests in the literature. One of them is the Augmented Dickey-Fuller (ADF) test
which is a unit root test. Its null hypothesis is that the series is non-stationary. If the p-value is less than 0.05, the null hypothesis can be
rejected, and the series can be considered stationary.
How To Make A Series Stationary?
•Difference Transform: Subtracting previous value with current value is called differencing. It is done to remove the dependency of values on
time. One can check the differenced series with the ADF test for stationary.
•Second differencing: If the result of the ADF test on the differenced series shows that the series is still non-stationary, then one can subtract the
differenced series again.
•Removing trend and seasonality by using HP-filter or band-pass filters and X12 ARIMA analysis.
Is It Necessary To Remove Trend And Seasonality?
•No. There are some models like Prophet, SARIMAX, etc., which take care of seasonality while modeling. The basic ARIMA model needs the
de-seasonal data.
Used in
•sales prediction, stock forecasting,
•weather forecasting,
•foot traffic prediction
• earthquake predictions
Methods widely used approaches :
•Winters exponential smoothing, the Autoregressive Integrated Moving SauravAverage
Banerjee (ARIMA) model, 2
•
various methods for analyzing time-series data:
•Autoregressive Integrated Moving Average (ARIMA) Models
•Seasonal Autoregressive Integrated Moving Average (SARIMA) Models
•Vector Autoregression (VAR)
•Exponential Smoothing models
•Prophet model.
•Once you have the data ready, you can divide the dataset into train and test data, train any of the above models, and test the performance using test data.
Two classes of models: • Trend + Seasonality + Stationary ARMA • Differencing + Stationary ARMA (consist of the ARIMA and Seasonal ARIMA models)
How To Compare Performance Of Different Models?
Comparision on metrics like:
•MSE (Mean squared error)
•RMSE(Root Mean Squared error)
•MAPE(Mean Absolute Percentage Error) etc.
Out of these metrics, MAPE has generally been considered a good metric for comparing models.
•What Are The Business Applications Of Time Series Analysis?
•The forecasting of future values and the identification of trends using linear regression methods, moving averages, variance forecasts, and wavelets
•Short-term time series modeling and ARIMA models
•Seasonal analysis using univariate (trends) and multivariate (stratification) techniques
•Space-time processes
•Measurement uncertainty
•Research using regression models
•Robustness
•Commodity markets
•Forecasting (all levels)
•Fractional statistics
•Finding anomalies
•Use-case With Above Mentioned Steps
•We have done time-series forecasting for knowing the future revenue of a company.
•We first checked the whole dataset for null values. If there are any null values, those rows are deleted.
•ADF test is done to check if the series is stationary.
•We have used two models for forecasting: The prophet model and Exponential Smoothing.
•The Prophet model takes the seasonal component of the series into consideration. We can mention whether there are seasonal components or not.
•Exponential smoothing has three versions:
– Simple exponential model: This model takes only detrend and deseasonalized data.
– Double exponential smoothing: This model considers only trends for time-series analysis.
– Holt’s winter exponential smoothing: This model considers both trend and seasonality and is the most widely used exponential smoothing method. Its results are more accurate and more diverse.
•Comparison between these models is done based on MAPE, MSE, and RMSE.
•The one which performs better is used for final forecasting.
•
•What Are The Objectives Of Time Series Analysis?
•To study the trend of the series
•To compute the time-series data
•To create a new data set from the existing one
•To analyze and compare the old and new data sets
•To detect the causality among the variables of the data set
•To study cross-sectional relationships between different types of variables
•To interpret the economic significance of the series data and their relationship with other factors in the economy
Saurav Banerjee 3
Time-series visualization of Index of
Industrial Production (IIP) of India.
Saurav Banerjee 4
Saurav Banerjee 5
Seasonality
time series has seasonality, it implies that there are repeating
patterns of almost constant length occurring over time. Keep in mind
that the time series model which takes into account seasonality is
SARIMA.
Source: https://ww2.mathworks.cn/help/econ/seasonal-
adjustment.html
Saurav Banerjee 6
Time series components
Saurav Banerjee 7
Saurav Banerjee 8
Saurav Banerjee 9
models
• State-Space models are a modern and very
powerful class of time series models.
Forecasting in these models is carried out via
an algorithm known as the Kalman Filter.
Saurav Banerjee 10
Acknowledgement
https://www.analyticsvidhya.com/blog/2021/07/time-series-analysis-a-beginner-friendly-
guide/,
11