Time Series

Vivek Salunkhe
6 min readFeb 9, 2022

--

Time series is a series of data points indexed (or listed or graphed) in time order or it can be considered as a sequence of data points that occurs in successive order over a particular period of time. A time series can be taken on any variable that changes over time.

Time Series Analysis. Image by author

Time Series Analysis:

It depicts the way of studying the characteristics of the target variable with respect to time as an independent variable or simply performing the forecast of the target variable by using time variable as a point of reference. The steps to be followed for performing time series analysis are as follows:

  1. Collection of appropriate time series data for suitable interval
  2. Identifying key components of several features with respect to time using graphs and plots
  3. Observing the key components of the time series
  4. Model Building & Forecasting i.e., predicting future activity.

Time Series Patterns or Key Components of Time Series:

  1. Trend: A trend exists when there is a long-term increase or decrease in the data. It does not have to be linear.
  2. Seasonality: A seasonal pattern occurs when a time series is a affected by seasonal factors such as the time of the year or the day of the week. Seasonality is always for a fixed and known frequency.
  3. Cyclic: A cycle occurs when the data exhibit rises and falls that are not of a 􀁿fixed frequency. These fluctuations are usually due to economic conditions, and are often related to the “business cycle”.
  4. Irregularity/Random: Unexpected situations or changes in a short time span.

Many time series include all the key patterns in them. So when choosing a forecasting method, we will first need to identify the time series patterns of the data, and then choose an appropriate method that is able to capture the patterns properly.

Time Series Patterns (Image by author)

Types of Time Series Data:

While working on time series there are typically two major types of data:

  1. Stationary : A dataset should follow the below thumb rules, without having Trend, Seasonality, Cyclical, and Irregularity component of time series.
  • The MEAN should be constant in the data during the analysis
  • The VARIANCE & COVARIANCE should be constant with respect to the time-frame

Thus, a stationary time series has statistical properties or moments that do not vary in time.

2. Non-Stationary : A Non Stationary time series is the status of a time series whose statistical properties are varying through time.

Stationary and Non Stationary Time Series (Image by author)

There are 3 typical methods in order to test any particular time series for Stationary. Those are as follows:

  1. Visual Tests: Simply verify all the criteria that are to be satisfied for a series to be stationary on the plot we are working upon.
  2. Global and Local Checks: We can calculate the mean, standard deviation of the entire time series (Global) and compare them with the mean, standard deviation of the data within fixed intervals (Local) and if it is equal we can refer the time series as Stationary.
  3. Augmented Dickey-Fuller (ADF) Test: Augmented Dickey–Fuller test (ADF) tests the null hypothesis that a unit root is present in a time series sample. The alternative hypothesis is different depending on which version of the test is used, but is usually stationarity or trend-stationarity. It is an augmented version of the Dickey-Fuller Test for a larger and more complicated set of time series models. The ADF test is the most popular statistical test and with the following assumptions.
  • Null Hypothesis (H0): Series is non-stationary, time-dependent (it has a unit root).
  • Alternate Hypothesis (HA): Series is stationary, not time-dependent (can’t be represented by a unit root).

The p-value determines the result of the test. If it is smaller than a critical threshold of 0.05 or 0.01, we reject the null hypothesis and conclude that the series is stationary. Otherwise, we fail to reject the null and conclude the series is non-stationary.

p-value >0.05 Fail to reject (H0)

p-value <= 0.05 Accept (H1)

Converting Non Stationary Series to Stationary Series:

Following are the methods followed to convert any non stationary time series to stationary:

  1. Detrending: It involves removing the trend effects from the given series and showing only the differences in values from the trend.
Detrending (Image by author)

2. De-seasonalizing: A time series where the seasonal component has been removed is called De-seasonalizing and the process is called as Seasonal Adjustment.

3. Differencing: The method for transforming the simplest non-stationary data to stationary is differencing. This process involves taking the differences of consecutive observations. For simple distributions, taking the first-order difference is enough to make it stationary.

Autocorrelation and Partial Autocorrelation:

Just as correlation measures the extent of a linear relationship between two variables, autocorrelation measures the linear relationship between lagged values of a time series i.e., the correlation of sequence with itself lagged by some number of time units.

ACF Plot (also called Correlogram or Auto Correlation Function Plot or Autocorrelation Plot) is a visual way to show serial correlation in data that changes over time. ACF is an (complete) auto-correlation function which gives us values of auto-correlation of any series with its lagged values.

Partial Autocorrelation is similar to autocorrelation and it shows the correlation of a sequence with itself lagged by some number of time units. However the twist is only the direct effect is shown, and all intermediary effects are removed.

PACF Plot is a Partial Auto-Correlation Function. Instead of finding correlations of present with lags like ACF, it finds correlation of the residuals (which remains after removing the effects which are already explained by the earlier intermediate lag(s)) with the next lag value hence ‘partial’ and not ‘complete’ as we remove already found variations before we find the next correlation.

To summarize the overall concept, ACF depicts the correlation between the lagged values of the time series in consideration with the indirect effect of each lag time period. However, PACF on the other hand depicts the correlation between the lagged values of the time series by neglecting the indirect effect & considering only the direct effect within fixed time periods.

Note: Before calculating autocorrelation & partial autocorrelation, the time series needs to be stationary.

White Noise:

Time series that show no autocorrelation are called white noise. A time series is considered to be a white noise when the following criteria are met:

  1. Mean is 0
  2. Standard Deviation is constant with time
  3. Correlation between lags is 0.

One of the important characteristic of white noise time series is that they are not predictable.

Importance of White Noise: Any time series is built up of the 2 major components i.e. the signal part (which can be modelled applied on our data) and the residual or error part i.e. the unpredictable part. So whenever we perform modelling on any time series data and we obtain the residual part resembling closely to white noise then it clearly indicates that the model we have used is a good fit on the data.

There are 3 typical methods in order to test any particular time series for White Noise. Those are as follows:

  1. Visual Tests: Simply verify all the 3 criteria that are to be satisfied for a series to be white noise on the plot we are working upon.
  2. Global and Local Checks: We can calculate the mean, standard deviation of the entire time series (Global) and compare them with the mean, standard deviation of the data within fixed intervals (Local) and if it is equal we can refer the time series as White Noise.
  3. Check for ACF: If there is no autocorrelation in the ACF Plot then we can simply refer the time series as White Noise.
White Noise Time Series (Image by author)

This blog is aimed to provide a complete theoretical intuition behind Time Series and various terminologies associated with it. I will be publishing another blog soon based on various time series models.

--

--