# Working of Forecasting in Analytics Plus

Analytics Plus offers a powerful forecasting engine that predicts future data points based on past data. The forecasting engine offers a range of customization such as number of units to be forecasted, number of data points to be ignored in the past data and the type of formatting to be applied over the forecasted data points.

The forecasting engine in Analytics Plus works based on the following factors:

## Auto-filling of missing values

When there are missing data points, the forecasting engine auto-fills the missing values in the data series based on the average between the previous and next available data point. If more than 40% of the original data series is missing, the forecasting process will be stopped, to avoid inaccurate forecasts.

## Periodicity Detection

Once the missing data points are auto-filled, the forecasting engine will detect the periodicity using the Autocorrelation method. This is done by dividing the data into small groups of fixed length and trying to identify a common pattern among the groups.

If a pattern cannot be detected, this step is repeated with groups of a different length.

## Identifying the Trend, Seasonality and Residual Components

The Analytics Plus forecasting engine has a built-in STL (Seasonality Trend Loess) library that decomposes data into Seasonality, Trend and Residual components using the periodicity identified in the previous step.

**Seasonality**: A common pattern that repeats in regular intervals in the data series.**Trend**: The underlying pattern of data variations.**Residual**: The irregular variations of data in a time series.

The STL library smooths any anomalies detected in the series, and requires the following values to determine the trend, seasonality and residual components.

The number of iterations required to converge on the trend, seasonality and residual components.

The number of points to be considered while smoothing each data point.

The number of iterations needed to recompute the smoothened data points based on the nearby data points.

These parameters are set by the forecasting engine to achieve best results.

### Non seasonal data

If the periodicity found by the STL library does not match the periodicity determined during Autocorrelation, the data is then assumed to be non-seasonal. In such scenarios, the STL library stops the process of identifying Seasonality, Trend and Residual values. Instead, the forecasting engine runs logarithmic, exponential and linear regressions over the non-seasonal data. The forecast points will then be produced based on the regression type that provides the best results.

## Regressions on Trend and Residual Components

After attaining the Seasonality, Trend and Residual components of each data points, the forecasting engine calculates the future trend and residual components with the help of linear, logarithmic and exponential regressions. The regression model used is decided based on the equations defined for correctness.

## Hindcasting using additive and multiplicative models

The final step of the forecasting engine is verifying the accuracy of the forecast. This is done using Hindcasting, which is the process of predicting the past data points and verifying the same with the original data points. The forecasting engine tries to forecast the last 30% of the past data points using Hindcasting, and checks the accuracy of the forecasted data points using additive model and multiplicative model.

Example of Additive Model: (Seasonality + Trend + Residual)

Example of Multiplicative Model: (Seasonality * Trend * Residual)

The results from the additive and multiplicative models will be verified using RMSE and LEPS measures, and the forecasted data points will then be plotted on a chart along with the actual data points.