MAPAx available for R & new MAPA package on CRAN

By | November 17, 2016

The previous version of the MAPA package implemented only the univariate aspect of the algorithm. Version 2.0.1 implements MAPAx as well, which allows incorporating regressors in your forecasts. In this paper we demonstrated the usefulness of temporal aggregation in the case of forecasting demand in the presence of promotions. In particular, we showed that MAPAx substantially outperformed regression promotions models (of this type), as well as exponential smoothing with promotional information (see Fig. 1).


Fig. 1. Bias and accuracy results for heavily promoted items. Description and details of the case study and experiment can be found here.

To use MAPAx call the usual mapa functions with the addition of the argument xreg. You can also control whether the regressors are transformed using principal components or not, using the argument pr.comp.  By default no transformation is performed. Note that MAPAx can only be used when type="es". It is recommended that when the regressors are related to high-frequency information, such as promotions, to use the combination options (argument comb): w.mean or w.median that weight high-frequency seasonality and xreg states more heavily.

The following example illustrates the strength of MAPAx when additional information is available. We model the demand of a promoted product with conventional MAPA and MAPAx. Fig. 2 provides the in-sample rolling forecasts and the out-of-sample forecast for 13 weeks.


Fig. 2. MAPA and MAPAx forecasts for the demand of a promoted product.

Observe that MAPAx models the past and future promotions and also provides tighter prediction intervals, since more information in the past sales is captured.

The stable version of the package with MAPAx is 2.0.1 and is available on CRAN. The development version, which includes the latest bugfixes, can be found on GitHub, where I also provide the versions available at both CRAN and GitHub so you can check whether you have the latest version or not. MAPAx, similar to high-frequency MAPA, requires the smooth package. Make sure you have the latest version of that as well!

4 thoughts on “MAPAx available for R & new MAPA package on CRAN

  1. Forecaster

    Excellent package and method. MAPAx would be very helpful for solving real world industry problems. I would like to know if MAPAx can handle decay effect /carryover effect that we typically see in promotional modeling in time series? Transfer function modelling can easily incorporate it.

    1. Nikos Post author

      The way that dynamic promotion effects can be easily incorporated in MAPAx is by adding leads and lags to the promotional events, much like with conventional regression modelling. Some dynamics are internal, depending on the underlying exponential smoothing model that is identified. Let me also add here that it may make a lot of sense to first log-transform your demand series to be able to model mnultiplicative promotional effects.
      The existing code does not allow for transfer function modelling of promotions, though in principle it would be quite easy to do so. If you would like to try temporal hierarchies and transfer functions right away, you may want to take a look at the thief package, which implements this working paper.


Leave a Reply

Your email address will not be published. Required fields are marked *