This function is a wrapper for PAL Intermittent Time Series Forecast (ITSF), which is a new forecast strategy for products with intermittent demand.

hanaml.IntermittentForecast(
  data,
  key,
  endog = NULL,
  p = NULL,
  q = NULL,
  forecast.num = NULL,
  optimizer = NULL,
  method = NULL,
  grid.size = NULL,
  optimize.step = NULL,
  accuracy.measure = NULL,
  ignore.zero = NULL,
  expost.flag = NULL,
  thread.ratio = NULL,
  penalty = NULL
)

Arguments

data

DataFrame
Data that contains the time-series analysis.

key

character
Specifies the ID (representing time-order) column of data.

endog

character, optional
Specifies name of the column for intermittent demand values.
Defaults to the 1st non-key column of data.

p

integer/numeric, optional
The smoothing parameter for demand, where:

  • -1 : optimizing this parameter automatically

  • positive integers : the specified value for smoothing, cannot exceed length of time-series for analysis.

The specified value cannot exceed the length of time-series for analysis.
Defaults to -1.

q

integer/numeric, optional
The smoothing parameter for the time-intervals between intermittent demands, where:

  • -1 : optimizing this parameter automatically

  • non-negative integers : the specified value for smoothing, cannot exceed the value of parameter p.

Defaults to -1.

forecast.num

integer/numeric, optional
Number of values to forecast.
Defaults to 1.

optimizer

c("simulated_annealing", "lbfgsb_default", "lbfgsb_grid"), optional
Specifies the optimization algorithm for automatically identifying parameters p and q:

  • "simulated_annealing" : Simulated annealing method(a probabilistic technique for approximating the global optimum of a given function).

  • "lbfgsb_default" : Bounded Limited-memory Broyden-Fletcher-Goldfarb-Shanno(LBFGSB) method with parameters p and q initialized by default scheme.

  • "lbfgsb_grid" : LBFGSB method, with parameter p and q initialized by grid search.

Defaults to "simulated_annealing".

method

character, optional
Specifies the method(or mode) for the output:

  • "sporadic" : Use the sporadic method.

  • "constant" : Use the constant method.

Defaults to "constant".

grid.size

integer/numeric, optional
Specifying the number of steps from the start point to the length
of data for grid search.
Only valid for when optimizer is set as "lbfgsb_grid".
Defaults to 20.

optimize.step

numeric, optional
Specifying minimum step for each iteration of LBFGSB method.
Defaults to 0.001.

accuracy.measure

character, optional
The criterion used for optimization, valid options include:
"mse", "rmse", "mae", "mape", "smape" and "mase".
Defaults to 'mse'.
NOTE: Specify a measure name if you want the corresponding measure value to be reflected in the output statistics.

ignore.zero

logical, optional

  • FALSE : Uses zero values in the input dataset when calculating 'mape'.

  • TRUE : Ignores zero values in the input dataset when calculating 'mape'.

Only valid when accuracy.measure is "mape".
Defaults to FALSE.

expost.flag

logical, optional

  • FALSE : Does not output the expost forecast, and just outputs the forecast values.

  • TRUE : Outputs the expost forecast and the forecast values.

Defaults to TRUE.

thread.ratio

numeric, optional
Specify the ratio of available threads for performing ITSF:

  • 0 : single thread.

  • 0~1 : percentage.

Defaults to 0.

penalty

numeric, optional
Penalty weight applied to the cost function to avoid over-fitting.

  • 1.6 for sporadic mode.

  • 0.4 for constant mode.

Value

A list of two DataFrames.

  • forecasts: DataFrame that stores the forecast values.

  • stats: DataFrame that stores the related statistics.

Details

Difference to constant weight of the Croston's method:

  • ITSF provides a exponential weight to estimate, which means the closer the data, the greater the weight.

  • ITSF does not need the initial value of non-zero demands and time interval between non-zero demands.

Examples

Time-series data for intermittent forecast:


> data
    ID  RAWDATA
1    0      0.0
2    1      1.0
3    2      4.0
4    3      0.0
5    4      0.0
6    5      0.0
7    6      5.0
8    7      3.0
9    8      0.0
10   9      0.0
11  10      0.0

Apply intermittent forecast to the given time-series data:


> res <- hanaml.IntermittentForecast(data = data,
                                     key = "ID",
                                     p = 3,
                                     forecast.num = 3,
                                     optimizer = "lbfgsb_grid",
                                     grid.size = 20,
                                     optimize.step = 0.011,
                                     expost.flag = FALSE,
                                     accuracy.measure = "mse",
                                     ignore.zero = FALSE,
                                     thread.ratio = 0.5)

Check the ouput DataFrames:


> res$forecasts
   ID   RAWDATA
1  12  2.831169
2  13  2.831169
3  14  2.831169

> res$stats
       STAT_NAME  STAT_VALUE
1            MSE   10.650383
2    LAST_DEMAND    3.892857
3  LAST_INTERVAL    0.000000
4          OPT_P    3.000000
5          OPT_Q    0.000000
6      OPT_STATE    0.000000