Teradata R Package Function Reference - 16.20 - ChangePointDetectionRT - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
16.20
created_date
February 2020
category
Programming Reference
featnum
B700-4007-098K

Description

The RtChangePointDetection function detects change points in a stochastic process or time series, using real-time change-point detection, implemented with these algorithms:

  1. Search algorithm: sliding window

  2. Segmentation algorithm: normal distribution

Usage

  td_changepoint_detection_rt_mle (
      data = NULL,
      data.partition.column = NULL,
      data.order.column = NULL,
      value.column = NULL,
      accumulate = NULL,
      segmentation.method = "normal_distribution",
      window.size = 10,
      threshold = 10,
      output.option = "CHANGEPOINT",
      data.sequence.column = NULL
  )

Arguments

data

Required Argument.
Specifies tbl_teradata object defining the input time series data.

data.partition.column

Required Argument.
Specifies partition by columns for data. Values to this argument can be provided as vector, if multiple columns are used for partition.

data.order.column

Required Argument.
Specifies order by columns for data.
Values to this argument can be provided as vector, if multiple columns are used for ordering.

value.column

Required Argument.
Specifies the name of the input table column that contains the time series data.

accumulate

Required Argument.
Specifies the names of the input table columns to copy to the output table.
Tip: To identify change points in the output table, specify the columns that appear in 'data.partition.column' and 'data.order.column'.

segmentation.method

Optional Argument.
Specify the segmentation method, normal distribution (in each segment, the data is in a normal distribution).
Default Value: "normal_distribution"

window.size

Optional Argument.
Specifies the size of the sliding window. The ideal window size depends heavily on the data. You might need to experiment with this value.
Default Value: 10

threshold

Optional Argument.
Specifies a numeric value that the function compares to ln(L1)-ln(L0). The definition of Log(L1) and Log(L0) are in td_changepoint_detection_mle. They are the logarithms of L1 and L2.
Default Value: 10

output.option

Optional Argument.
Specifies the output table columns.
Default Value: "CHANGEPOINT"
Permitted Values: changepoint, segment, verbose

data.sequence.column

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

Value

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

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    loadExampleData("changepointdetectionrt_example", "cpt")
    
    # Create remote tibble objects.
    cpt <- tbl(con, "cpt")
    
    # Example 1 - ChangePointThreshold 10, Window Size 3, Default Output.
    td_changepoint_detection_rt_out1 <- td_changepoint_detection_rt_mle(data = cpt ,
                                                                   data.partition.column = c("sid"),
                                                                   data.order.column = c("id"),
                                                                   value.column = "val",
                                                                   accumulate = c("sid","id"),
                                                                   window.size = 3,
                                                                   threshold = 10
                                                                   )
    
    # Example 2 - ChangePointThreshold 20, Window Size 3, VERBOSE Output.
    td_changepoint_detection_rt_out2 <- td_changepoint_detection_rt_mle(data = cpt,
                                                                   data.partition.column = c("sid"),
                                                                   data.order.column = c("id"),
                                                                   value.column = "val",
                                                                   accumulate = c("sid","id"),
                                                                   window.size = 3,
                                                                   threshold = 20,
                                                                   output.option = "verbose"
                                                                   )