aid: Automatic Identification of Demand

View source: R/AutomaticDemandIdentifier.R

aidR Documentation

Automatic Identification of Demand

Description

The function applies several models on the provided time series and identifies what type of demand it is based on an information criterion.

Usage

aid(y, ic = c("AICc", "AIC", "BICc", "BIC"), level = 0.99,
  loss = "likelihood", ...)

aidCat(data, ...)

Arguments

y

The vector of the data.

ic

Information criterion to use.

level

The confidence level used in stockouts identification.

loss

The type of loss function to use in model estimation. See alm for possible options.

...

Other parameters passed to the alm() function. In case of the aidCat() function, the aid() parameters can be passed here.

data

The dataframe or a matrix to which the aid function should be applied

Details

In the first step, function creates inter-demand intervals and fits a model with LOWESS of it assuming Geometric distribution. The outliers from this model are treated as potential stock outs.

In the second step, the function creates explanatory variables based on LOWESS of the original data, then applies Normal, Normal + Bernoulli models and selects the one that has the lowest IC. Based on that, it decides what type of demand the data corresponds to: regular or intermittent. Finally, if the data is count, the function will identify that.

Value

aid() returns an object of class "aid", which contains:

  • y - The original data;

  • models - All fitted models;

  • ICs - Values of information criteria;

  • type - The type of the identified demand;

  • stockouts - List with start and end ids of potential stockouts;

  • new - Binary showing whether the data start with the abnormal number of zeroes. Must be a new product then;

  • obsolete - Binary showing whether the data ends with the abnormal number of zeroes. Must be product that was discontinued (obsolete).

aidCat() returns an object of class "aidCat", which contains:

  • categories - the vector with the names of categories for each time series;

  • types - the vector with the count of series in each category;

  • anomalies - the vector that contains counts of cases where product was flagged as new, obsolete and having stockouts.

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

Examples

# Data from Poisson distribution
y <- rpois(120, 0.7)
aid(y)

xreg <- cbind(x1=rpois(100,1), x2=rpois(100,2),
              x3=rpois(100,5), x4=rnorm(100,10,2))
aidCat(xreg) |> plot()

config-i1/greybox documentation built on Jan. 22, 2025, 9:52 p.m.