Teradata R Package Function Reference | 17.00 - 17.00 - ArimaPredict - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

The ARIMAPredict function takes as input the ARIMA model produced by the ARIMA (td_arima_mle) function and predicts a specified number of future values (time point forecasts) for the modeled sequence.

Usage

  td_arima_predict_mle (
      object = NULL,
      residual.table = NULL,
      n.ahead = 1,
      partition.columns = NULL,
      object.sequence.column = NULL,
      residual.table.sequence.column = NULL,
      object.partition.column = NULL,
      residual.table.partition.column = NULL,
      object.order.column = NULL,
      residual.table.order.column = NULL
  )

Arguments

object

Required Argument.
Specifies the model tbl_teradata generated by td_arima_mle.
This argument can accept either a tbl_teradata or an object of "td_arima_mle" class.

object.partition.column

Required Argument.
Specifies Partition By columns for "object".
Values to this argument can be provided as a vector, if multiple columns are used for partition.
Types: character OR vector of Strings (character)

object.order.column

Optional Argument.
Specifies Order By columns for "object".
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

residual.table

Required Argument.
Specifies the name of the tbl_teradata that contains the original input parameters and their residuals. This tbl_teradata is the residual tbl_teradata generated by the td_arima_mle function.

residual.table.partition.column

Required Argument.
Specifies Partition By columns for "residual.table".
Values to this argument can be provided as a vector, if multiple columns are used for partition.
Types: character OR vector of Strings (character)

residual.table.order.column

Required Argument.
Specifies Order By columns for "residual.table".
Values to this argument can be provided as a vector, if multiple columns are used for ordering.
Types: character OR vector of Strings (character)

n.ahead

Optional Argument.
Specifies the number of steps to forecast after the end of the time series. This value must be a positive integer.
Default Value: 1
Types: integer

partition.columns

Required Argument.
Specifies the partition columns that are in model tbl_teradata and residual tbl_teradata.
Types: character OR vector of Strings (character)

object.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "object". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

residual.table.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "residual.table". The argument is used to ensure deterministic results for functions which produce results that vary from run to run.
Types: character OR vector of Strings (character)

Value

Function returns an object of class "td_arima_predict_mle" which is a named list containing object of class "tbl_teradata".
Named list member can be referenced directly with the "$" operator using the name: result.

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("arima_example", "milk_timeseries")

    # Create object(s) of class "tbl_teradata".
    milk_timeseries <- tbl(con, "milk_timeseries")

    # Generate arima model using "orders" parameter.
    td_arima_out <- td_arima_mle(data = milk_timeseries,
                                 timestamp.columns = "period",
                                 value.column = "milkpound",
                                 orders = "3,0,0",
                                 include.mean = TRUE
                                 )

    # Example 1: Using the generated Arima model to find predictions.
    td_arima_predict_out <- td_arima_predict_mle(td_arima_out,
                                          object.partition.column='td_arima_partition_id',
                                          residual.table=td_arima_out$residual.table,
                                          residual.table.partition.column='td_arima_partition_id',
                                          residual.table.order.column='period',
                                          partition.columns='td_arima_partition_id',
                                          n.ahead=15
                                          )

     # Example 2: Alternatively use the predict S3 method to find predictions.
     predict_out <- predict(td_arima_out,
                            object.partition.column='td_arima_partition_id',
                            residual.table=td_arima_out$residual.table,
                            residual.table.partition.column='td_arima_partition_id',
                            residual.table.order.column='period',
                            partition.columns='td_arima_partition_id',
                            n.ahead=15
                            )

     # Example 3: Using coefficient tbl_teradata from a presisted Arima model generated 
     # by td_arima_mle() function.
     # Persist the models generated by td_arima_mle() function.
     copy_to(con, df = td_arima_out$coefficient, name = "test_td_arima_coefficients", 
             overwrite = TRUE)
     copy_to(con, df = td_arima_out$residual.table, name = "test_td_arima_residualtable", 
             overwrite = TRUE)

     # Create object(s) of class "tbl_teradata".
     arima_coefficients <- tbl(con, "test_td_arima_coefficients")
     arima_residualtable <- tbl(con, "test_td_arima_residualtable")

     # Find prediction.
     td_arima_predict_out <- td_arima_predict_mle(object=arima_coefficients,
                                          object.partition.column='td_arima_partition_id',
                                          residual.table=arima_residualtable,
                                          residual.table.partition.column='td_arima_partition_id',
                                          residual.table.order.column='period',
                                          partition.columns='td_arima_partition_id',
                                          n.ahead=15
                                          )