lt.dist: Empirical quantiles of the demand over the lead time

View source: R/tsint.R

lt.distR Documentation

Empirical quantiles of the demand over the lead time

Description

Calculate the empirical quantiles of the demand over the lead time from the cumulative in-sample forecast errors, either for a model fitted with the functions of the package, for any lead time and probabilities without refitting it, or for any forecast that is constant over the horizon.

Usage

lt.dist(
  data,
  frc.in = NULL,
  frc.out = NULL,
  h = NULL,
  probs = c(0.9, 0.95),
  qtype = 7
)

Arguments

data

A model fitted with crost, tsb, sexsm, crost.ma, or imapa. Alternatively, a time series, which can be a vector, a ts object, or a data frame, in which case only the first column is used.

frc.in

In-sample forecasts, of the same length as data, where frc.in[t] is the forecast for period t made at the end of period t-1. Periods without a forecast should be NA. Not used when data is a fitted model.

frc.out

Out-of-sample forecast from the end of the sample. Only the first value is used. Not used when data is a fitted model.

h

Lead time, see the section "Lead time quantiles" in crost. When data is a fitted model, its horizon is used if h is NULL.

probs

Probabilities of the quantiles.

qtype

Type of empirical quantile calculation, passed to quantile.

Details

This is the calculation used by the forecasting functions of the package when probs is provided. With a fitted model, the stored series and in-sample forecasts are used, so the lead time and the probabilities can be changed without optimising the model again. Note that the parameters of a model optimised with the cost functions "msce" or "mace" depend on the horizon used when fitting it. For iMAPA, the forecasts from each in-sample origin are calculated if they were not calculated when fitting, which can take some time.

With a time series and forecasts produced otherwise, the forecast made at each origin is assumed to be constant over the next h periods, as is the case for all methods in the package, so that the cumulative forecast from origin t-1 is h*frc.in[t].

Value

A list containing:

h

Lead time.

probs

Probabilities.

frc

Cumulative forecast over the lead time.

quantile

Quantiles of the demand over the lead time, i.e., the order-up-to level or the reorder point.

ss

Safety stock, i.e., the quantiles minus the cumulative forecast.

errors

In-sample cumulative errors.

origin

Origin of each cumulative error, i.e., the period at the end of which the forecast was made, so that the error covers periods origin+1 to origin+h. Origin 0 is the start of the sample. Periods are counted from the first observation, also for ts objects.

n

Number of cumulative errors.

qtype

Type of quantile calculation.

Author(s)

Nikolaos Kourentzes, nikolaos@kourentzes.com

References

Saoud, P., Kourentzes, N., and Boylan, J. E. (2022). Approximations for the lead time variance: A forecasting and inventory evaluation. Omega, 110, 102614. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.omega.2022.102614")}

See Also

crost, forecast.tsint.

Examples

# Different lead times and probabilities for a fitted model, without refitting
fit <- crost(ts.data1, type="sba")
lt.dist(fit, h=3)
lt.dist(fit, h=6, probs=0.99)

# Same result as crost(ts.data1, h=3, probs=c(0.9,0.95))$lt
fit <- crost(ts.data1, h=3)
lt.dist(ts.data1, fit$frc.in, fit$frc.out, h=3)

# A simple moving average of the last 12 periods as the forecast
y <- as.numeric(ts.data1)
frc <- c(rep(NA,12), as.numeric(stats::filter(y, rep(1/12,12), sides=1))[12:(length(y)-1)])
lt.dist(y, frc, mean(tail(y,12)), h=3, probs=0.95)


tsintermittent documentation built on Nov. 14, 2026, 5:06 p.m.