Forecasting Using Time Series
By: Heena Rijhwani
Tags: Timeseries

Forecasting is a frequently used application of predictive analytics as it has a significant impact on both the top line and bottom line of an organization. Forecasting demands for products and services is an important input for both long-range and short-range planning. Various capacity planning problems such as manpower planning, machine capacity, warehouse capacity, materials requirements planning will depend on the forecasted demand of the product/service.

Budget allocations for marketing, promotions and advertisements are usually made based on forecasting outcomes.

Examples of forecasting include:

Boeing 747–400 has more than 6 million parts and several thousand unique parts. Forecasting demands for spare parts is important since non-availability of mission-critical parts can have detrimental effects and turn out to be very expensive for the airlines.

Walmart supercentres stock over 142,000 different items. Stock must be maintained for each and every product sold and demand for the products must be predicted as accurately as possible in oder to increase revenue and sales.

Demand for products and service is not the only application of forecasting, manpower planning also requires the use of sophisticated models.

Indian information technology companies struggle to manage the right level of manpower for each skill required to manage their business. This would involve forecasting business opportunities, skills required to manage current and future projects, etc.

TIME-SERIES DATA

The time-series data Yt is a random variable, usually collected at regular time intervals and in chronological order.

Univariate time-series data: Time-series data that contains observations of just a single variable (such as demand of a product at time t).

Multivariate time-series data: If the data consists of more than one variable, for example, demand for a product at time t, price at time t, amount of money spent by the company on promotion at time t, competitors’ price at time t, etc.

COMPONENTS OF TIME-SERIES DATA

Trend Component (Tt): Trend is the consistent long-term upward or downward movement of the data.

Seasonal Component (St): Seasonal component is the repetitive upward or downward movement from the trend that occurs within a calendar year at fixed intervals such as seasons, quarters, months, days of the week, etc.

Cyclical Component (Ct): Cyclical component is fluctuation around the trend line at random intervals that happens due to macro-economic changes such as recession, unemployment, etc. Cyclical fluctuations have repetitive patterns.

Irregular Component (It): Irregular component is the white noise or random uncorrelated changes that follow a normal distribution with mean value of 0 and constant variance.

There are several forecasting techniques such as moving average, exponential smoothing, and Auto-Regressive Integrated Moving Average (ARIMA) that are used across various industries.

Moving average and exponential smoothing predict the future value of a time-series data as a function of past observations. Regression-based models such as auto-regressive (AR), moving average (MA), auto-regressive and moving average (ARMA), ARIMA use more sophisticated regression models. Using complex mathematical models does not guarantee a more accurate forecast. Simple moving average technique may outperform complex ARIMA models in many cases.

DECOMPOSING TIME SERIES

Time-series data can be modeled as addition or product of trend, seasonality, cyclical, and irregular components.

Additive time-series model: These models assume that the seasonal and cyclical components are independent of the trend component. Additive models are not very common, since in many cases the seasonal component may not be independent of the trend.

Additive time-series model is given by

Yt = Tt + St + Ct + It

Multiplicative time-series model: These models are more common and are a better fit for many datasets. Seasonality has a multiplicative effect on sales based on a trend over the years. So, in many cases the seasonality effect is multiplied with the trend and not just added as in additive model.

It is given by

Yt = Tt x St x Ct x It

For decomposing time-series data, we can leverage the following libraries:

1.statsmodel.tsa provides various features for time-series analysis.

2. seasonal_decompose() in statsmodel.tsa.seasonal decomposes a time series into trend, seasonal, and residuals. It takes frequency parameters; for example, the frequency is 12 for monthly data.

AUTO-REGRESSIVE INTEGRATED MOVING AVERAGE

Auto-regressive and moving average models are popular models that are frequently used for forecasting. They are combined to create models such as auto-regressive moving average (ARMA) and auto-regressive integrated moving average (ARIMA) models.

Auto-Regressive Models- Auto-regression is regression of a variable on itself measured at different time points. Auto-regressive model with lag 1, AR (1), is given by:

An important task in using the auto-regressive model is model identification, which is identifying the value of p (the number of lags).

A standard approach for model identification is using auto-correlation function and partial auto correlation function.

Moving Average Processes- Moving average processes are regression models in which past residuals are used to forecast future values of the time-series data.

A moving average process of lag 1 can be written as:

The model in the equation can be generalized to q lags.

The value of q (number of lags) in a moving average process can be identified using the following rules:

1.Auto-correlation value is significant for first q lags and cuts off to zero.

2.The partial auto-correlation function decreases exponentially.

Auto-regressive moving average (ARMA) Model- ARMA is a combination auto-regressive and moving

average process. ARMA (p, q) process combines AR(p) and MA(q) processes.

The values of p and q in an ARMA process can be identified using the following thumb rules:

1.Auto-correlation values are significant for first q values (first q lags) and cuts off to zero.

2.Partial auto-correlation values are significant for first p values and cuts off to zero.

Auto-Regressive Integrated Moving Average(ARIMA) Model- ARMA models can be used only when the time-series data is stationary. ARIMA models are used when the time-series data is non-stationary.

Time-series data is called stationary if the mean, variance, and co-variance are constant over time.

ARIMA has the following three components and is represented as ARIMA (p, d, q):

1.AR component with p lags AR(p).

2.Integration component (d).

3.MA with q lags, MA(q).