Time Series forecasting : An Introduction
By: Ankur Raja
Tags: Data Science, Time Series Analysis, Statistics, Time Series Forecasting

In this blog, I am going to give an overview of Time Series data and some terms associated with it.

First of all what is a Time Series data, according to Wikipedia: “A time series is a series of data points indexed (or listed or graphed) in time order.”

To put it in simple words any data which has been recorded sequentially over time is time series data. Some of the examples are annual revenue of a company, monthly demand of a product, the daily maximum temperature of a city, number of customers visiting a restaurant every hour and number of hits on a particular website every minute or second. From the above examples, it should be clear that the time series data can be recorded at any period i.e. yearly, monthly, daily, hourly, per minute / per seconds or any other unit of time.

Time Series data can be used to forecast future values and which, in turn, helps in better planning. For example, if a website owner knows the number of visitors on his website in future he can make better decisions in managing his website traffic or if a shop knows the future sales number of a product they will be in a better position to keep stocks of that product.

Let’s try understanding some terms related to time series like seasonality, trend, cyclical patterns and stationarity.

Seasonality: Seasonality is the presence of variations at regular intervals of time in time series data. It exists when a series is influenced by seasonal factors. The interval is generally less than a year such as weekly, monthly, quarterly, half-yearly, yearly etc.

Champagne

Let’s try to understand this using a time series plot of champagne sales dataset. ( Makridakis and Wheelwright, 1989). The dataset provides monthly champagne sales from January 1964 to September 1972 for Perrin Freres brand.

Seasonality in Monthly Champagne Sales

From the above plot, we can observe that there is a peak in sales towards the end of every year(which can be attributed to the Christmas celebrations). This is a good example of seasonality as the pattern is repeating annually.

Detecting seasonality and its type is important as we need to take it into account while deciding on the forecasting models. For example, using ETS with or without seasonality or using ARIMA vs SARIMA(Seasonal ARIMA) for a given data.

There are multiple graphical tools to detect seasonality like run sequence plot, seasonal plots, seasonal subseries plots, multiple box plots and autocorrelation plots(ACF). Some mathematical tests like ch, hegy and ocsb are also used to detect seasonal stability. We will not be discussing them here in detail.

Trend: In Time Series analysis trend is a gradual shift towards relatively lower or higher values over a long period of time.

If values tend to increase towards a higher value for a significant period of time, it’s called an uptrend, whereas if values tend to decrease towards a lower value for a considerable time period it’s known as a downtrend. If values don’t shift towards lower or higher values its referred to as horizontal trend.

No, its shampoo 😉

Let’s try to understand this visually using shampoo sales dataset ( Makridakis, Wheelwright and Hyndman (1998) ). We can observe (in the below graph) the shampoo sales are increasing towards a high value over the long term. This is an example of an upward trend.

Upward Trend in Monthly Shampoo Sales

Similar to seasonality detecting trend is very important, as we need to consider it while picking up the right forecasting model.

We can detect a trend in data by observing its trend component from its decomposition plot. We will be learning more about time series decomposition in another blog.

Trend component of champagne data

Cyclical Patterns: Cyclical patterns are described as variations which are of length larger than a year. It should not be confused with seasonality. Generally, the average span of cycles is longer than the span of a seasonal pattern, and the magnitude of cycles are more varied compared to seasonal patterns.