| imapa | R Documentation |
Forecast intermittent demand time series by modelling them at multiple temporal aggregation levels and combining the forecasts, selecting between Croston's method, SBA, and SES at each level.
imapa(
data,
h = 10,
w = NULL,
minimumAL = 1,
maximumAL = NULL,
comb = c("mean", "median"),
init.opt = c(TRUE, FALSE),
paral = c(0, 1, 2),
outplot = c(0, 1, 2, 3, 4),
model.fit = NULL,
na.rm = c(FALSE, TRUE),
probs = NULL,
qtype = 7,
cl = NULL
)
data |
Intermittent demand time series. This can be a vector, a |
h |
Forecast horizon. When |
w |
Smoothing parameters for Croston's method and SBA. If |
minimumAL |
Lowest aggregation level to use. |
maximumAL |
Highest aggregation level to use. If |
comb |
Combination operator, |
init.opt |
If |
paral |
Use parallel processing: |
outplot |
Plot of the forecast:
All plots are also available afterwards with |
model.fit |
Optional input with model types and parameters. This can be the
|
na.rm |
If |
probs |
Probabilities of the quantiles of the demand over the lead time
|
qtype |
Type of empirical quantile calculation, passed to
|
cl |
Cluster to use when |
Temporal aggregation sums the series into non-overlapping buckets of several
periods. At higher aggregation levels there are fewer zeros, so the series becomes
easier to forecast, but the best level differs between series and is not known in
advance. iMAPA avoids this choice by using all levels from minimumAL to
maximumAL (Petropoulos and Kourentzes, 2015). At each level, the first
observations are dropped where needed, so that all buckets are complete; the
aggregated series is classified with the PKa scheme of idclass; and
Croston's method, SBA, or SES is fitted accordingly, with parameters optimised using
MAR. The forecast of each level is divided equally over the periods of a bucket, and
the forecasts of all levels are combined. Levels with fewer than four aggregated
observations, or fewer than two non-zero values, are not used.
The forecast is a demand rate, constant over the horizon. The in-sample forecast
frc.in of each level is produced at the aggregated frequency, so within each
bucket it is the forecast made at the start of the bucket.
An object of class imapa, which is a list containing:
frc.in |
In-sample demand rate. |
frc.out |
Out-of-sample demand rate. |
summary |
An array containing information for each aggregation level:
|
model.fit |
Parameters and initialisation values of the fitted model at each aggregation level, with aggregation level and model information. |
lt |
Only when |
fit.info |
Information used by the methods of the object, such as the series, the forecast from the end of the sample, and the cost function. Not intended for direct use. |
The object can be used with print, summary, plot, coef,
fitted, and forecast.
The quantiles are calculated as described in crost, from the cumulative
errors over h periods. Because the in-sample forecasts of the aggregation
levels are made at the start of each bucket, rather than at every period, the
cumulative errors are calculated from forecasts made at every in-sample origin, using
the fitted models of each level with fixed parameters. Levels that do not yet have
enough observations at an origin are left out of the combination at that origin.
This requires forecasts from every origin and every level, so it is slower than the
other methods; paral can be used to speed it up. Unlike the other methods, the
cumulative cost functions MSCE and MACE are not offered, as temporal aggregation
already targets the demand over multiple periods.
Nikolaos Kourentzes, nikolaos@kourentzes.com
Petropoulos, F., and Kourentzes, N. (2015). Forecast combinations for intermittent demand. Journal of the Operational Research Society, 66(6), 914–924. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1057/jors.2014.62")}
plot.imapa, idclass, crost.
# iMAPA with a plot of the combined forecast
fit <- imapa(ts.data1, outplot=1)
summary(fit)
# Forecasts of each aggregation level and the models selected
plot(fit, view="levels")
plot(fit, view="selection.detail")
# Fewer aggregation levels, combined with the median
imapa(ts.data1, maximumAL=12, comb="median")$frc.out
# Reuse the fitted models, for example on an updated series
imapa(ts.data1, model.fit=fit)$frc.out
# Quantiles of the demand over a lead time of 3 periods
fit <- imapa(ts.data1, h=3, maximumAL=12, probs=c(0.9,0.95), outplot="leadtime")
fit$lt$quantile
# Parallel processing with a cluster
cl <- parallel::makeCluster(2)
imapa(ts.data1, paral=1, cl=cl)$frc.out
parallel::stopCluster(cl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.