Similar to other predict methods, this function predicts fitted values from a fitted "hanaml.AdditiveModelForecast" object.

# S3 method for AdditiveModelForecast
predict(
  model,
  data,
  key = NULL,
  endog = NULL,
  exog = NULL,
  logistic.growth.capacity = NULL,
  interval.width = NULL,
  uncertainty.samples = NULL,
  show.explainer = NULL,
  decompose.seasonality = NULL,
  decompose.holiday = NULL,
  group.key = NULL,
  group.params = NULL
)

Format

S3 methods

Arguments

model

R6Class object
A "hanaml.AdditiveModelForecast" object for prediction.

data

DataFrame
Input data which includes key and endog columns and may contain exog column(s).

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.

exog

character or list of characters, optional
An optional array of exogenous variables.
Defaults to NULL.

logistic.growth.capacity

numeric, optional
Specify the carrying capacity for logistic growth.
Mandatory and valid only when the growth attribute is "logistic".
Defaults to NULL.

interval.width

numeric, optional
Width of the uncertainty intervals.
Defaults to 0.8.

uncertainty.samples

numeric, optional
Number of simulated draws used to estimate uncertainty intervals.
Defaults to 1000.

show.explainer

logical, optional
Indicate whether to invoke the AdditiveModelForecast with explanations function in the predict function.
If TRUE, the contributions of trend, seasonal, holiday and exogenous variables are shown in a attribute called explainer.
Note that in the Massive mode, the result of predict function is always with explanations and this parameter is not valid.
Defaults to FALSE.

decompose.seasonality

logical, optional
Specify whether or not seasonal component will be decomposed.
In single mode, this parameter is valid only when show.explainer is TRUE.
Defaults to FALSE.

decompose.holiday

logical, optional
Specify whether or not holiday component will be decomposed. In single mode, this parameter is valid only when show.explainer is TRUE.
Defaults to FALSE.

group.key

character, optional
The column of group key. The data type can be INT or NVARCHAR/VARCHAR. If data type is INT, only parameters set in the group.params are valid. This parameter is only valid when massive is TRUE.
Defaults to the first column of data if group.key is not provided.

group.params

list, optional
If the massive mode is activated (massive = TRUE), input data shall be divided into different groups with different parameters applied.
An example is as follows:


> ad <- hanaml.AdditiveModelForecast(data=df,
                                     massive=TRUE,
                                     key='TIMESTAMP',
                                     endog='Y',
                                     group.key='GROUP_ID',
                                     group.params=list('Group_1'=list('seasonality.mode'='additive')))
> mres <- predict(model=ad,
                  data=pred.df,
                  key='TIMESTAMP',
                  endog='Y',
                  group.key='GROUP_ID',
                  group.params=list('Group_1'=list('logistic.growth.capacity'=3))

Defaults to NULL.

Value

Predicted values are returned as a DataFrame, structured as follows.

  • ID column: type timestamp.

  • YHAT: type DOUBLE, representing predicted values.

  • YHAT_LOWER: type DOUBLE, lower bound of confidence region.

  • YHAT_UPPER: type DOUBLE, upper bound of confidence region.

Examples

Input DataFrame data2:


> data2$Collect()
   TIMESTAMP          X
1 2007-12-11 -0.6361264
2 2007-12-12  3.0925087
3 2007-12-13 -0.7373356
4 2007-12-14 -3.1421910

Call the function with a "hanaml.AdditiveModelForecast" object amf and obtain the result:


> res <- predict(amf, data2)
   TIMESTAMP       YHAT YHAT_LOWER YHAT_UPPER
1 2007-12-11  0.1378272  -1.922812  2.2191343
2 2007-12-12 -0.5874185  -2.610632  1.4819355
3 2007-12-13 -1.3126642  -3.376615  0.5591713
4 2007-12-14 -2.0379099  -4.086953  0.1144007

If you want to show the explainer, please call:


> res <- predict(amf, data2, show.explainer=TRUE)
> print(amf$explainer$Collect())
    TIMESTAMP      TREND SEASONAL HOLIDAY EXOGENOUS
1  2007-12-11  0.1378272       {}      {}        {}
2  2007-12-12 -0.5874185       {}      {}        {}
3  2007-12-13 -1.3126642       {}      {}        {}
4  2007-12-14 -2.0379099       {}      {}        {}