hanaml.Croston is a R wrapper for SAP HANA PAL Croston algorithm.

hanaml.Croston(
  data,
  key = NULL,
  endog = NULL,
  alpha = NULL,
  forecast.num = NULL,
  method = NULL,
  accuracy.measure = NULL,
  ignore.zero = NULL,
  expost.flag = NULL
)

Arguments

data

DataFrame
DataFrame containting the data.

key

character, optional
Name of the ID column.
Defaults to the first column if not provided.

endog

character, optional
The endogenous variable, i.e. time series.
Defaults to the first non-ID column.

alpha

double, optional
Value of the smoothing constant alpha (0 < alpha < 1).
Defaults to 0.1.

forecast.num

integer, optional
Number of values to be forecast.
Defaults to 0.

method

character, optional

  • 'sporadic': Use the sporadic method.

  • 'constant': Use the constant method.

Defaults to "sporadic".

accuracy.measure

character or list of characters, optional
Specifies the method of accuracy evaluation.

  • mpe: Mean percentage error.

  • mse: Mean squared error.

  • rmse: Root mean squared error.

  • et: Error total.

  • mad: Mean absolute deviation.

  • mase: Out-of-sample mean absolute scaled error.

  • wmape: Weighted mean absolute percentage error.

  • smape: Symmetric mean absolute percentage error.

  • mape: Mean absolute percentage error.

No default value.

ignore.zero

logical, optional

  • FALSE: Uses zero values in the input dataset when calculating "mpe" or "mape".

  • TRUE: Ignores zero values in the input dataset when calculating "mpe" or "mape".

Only valid when accuracy.measure is "mpe" or "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.

Value

Return a list of two DataFrames:

  • DataFrame 1
    Forecast values.

  • DataFrame 2
    Statistics analysis content.

Details

The Croston method is a forecast strategy for products with intermittent demand.
The Croston method consists of two steps. First, separate exponential smoothing estimates are made of the average size of a demand. Second, the average interval between demands is calculated. This is then used in a form of the constant model to predict the future demand.

Examples

Input DataFrame data:


> data$Collect()
   ID RAWDATA
1   0       0
2   1       1
3   2       4
4   3       0
5   4       0
6   5       0
7   6       5
8   7       3
9   8       0
10  9       0
11 10       0

Call the function:


> cesm <- hanaml.Croston(data = data,
                         alpha=0.1,
                         forecast.num=1,
                         method="sporadic",
                         accuracy.measure="mape")

Output:


> cesm[[2]]$Collect()
  STAT_NAME    STAT_VALUE
1      MAPE     0.2432182