Teradata R Package Function Reference - 16.20 - DWT2D - 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 DWT2D function implements Mallat's algorithm (an iterate algorithm in the Discrete Wavelet Transform field) on 2-dimensional matrices and applies wavelet transform on multiple sequences simultaneously.

Usage

  td_dwt2d_mle (
      data = NULL,
      input.columns = NULL,
      index.columns = NULL,
      range = NULL,
      wavelet = NULL,
      wavelet.filter = NULL,
      level = NULL,
      extension.mode = "sym",
      compact.output = TRUE,
      partition.columns = NULL,
      data.sequence.column = NULL,
      wavelet.filter.sequence.column = NULL
  )

Arguments

data

Required Argument.
Specifies the name of the tbl_teradata that contains the sequences to be transformed.

input.columns

Required Argument.
Specifies the names of the columns in the input tbl_teradata that contains the data to be transformed. These columns must contain numeric values between -1e308 and 1e308. The function treats NULL as 0.
Types: character OR vector of Strings (character)

index.columns


Required Argument. Specifies the columns that contain the indexes of the input sequences. For a matrix, this takes a vector of two elements, the first element is the column containing the x coordinates and second element is the column containing the y coordinates. Types: character OR vector of Strings (character)

range

Optional Argument.
Specifies the start and end indexes of the input data, all of which must be integers.
The default values for each sequence are:

  1. starty: minimum y index

  2. startx: minimum x index

  3. endy: maximum y index

  4. endx: maximum x index.


Specify the argument value in the format '(startx,starty),(endx,endy)'. The function treats any NULL value as 0. The range can specify a maximum of 1,000,000 cells.
Types: character

wavelet

Optional Argument.
Required if 'wavelet.filter' argument is not specified. Specifies a wavelet filter name. Refers to the supported wavelet filter names from td_dwt_mle function's 'wavelet' Argument.
Types: character

wavelet.filter

Optional Argument.
Required if 'wavelet' argument is not specified. Specifies the name of the tbl_teradata that contains the coefficients of the wavelet filters.

level

Required Argument.
Specifies the wavelet transform level. The value of the wavelet transform level must be an integer in the range [1, 1000]. Types: numeric

extension.mode

Optional Argument.
Specifies the method for handling border distortion, an extension mode from the supported extension modes specified below - td_dwt_mle "extension.mode" argument. Default Value: "sym"
Permitted Values: sym, zpd, ppd
Types: character

compact.output

Optional Argument.
Specifies whether to ignore rows in which all coefficient values have an absolute value less than 1e-12. For a sparse input matrix, ignoring such rows reduces the output table size. Default Value: TRUE
Types: logical

partition.columns

Optional Argument.
Specifies the names of the partition.columns, which identify the sequences. Rows with the same partition.columns values belong to the same sequence. If you specify multiple partition.columns, then the function treats the first one as the distribute key of the output and meta tables. By default, all rows belong to one sequence, and the function generates a distribute key column named dwt_idrandom_name in both the coefficient table and the meta table. In both tables, every cell of dwt_idrandom_name has the value 1.
Types: character OR vector of Strings (character)

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.
Types: character OR vector of Strings (character)

wavelet.filter.sequence.column

Optional Argument.
Specifies the vector of column(s) that uniquely identifies each row of the input argument "wavelet.filter". 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_dwt2d_mle" which is a named list containing Teradata tbl objects.
Named list members can be referenced directly with the "$" operator using following names:

  1. coefficient

  2. meta.table

  3. output

Examples

    # Get the current context/connection
    con <- td_get_context()$connection
    
    # Load example data.
    # dataset contains climate data in cities in California (CA), Texas (TX), and Washington (WA).
    # The cities are represented by two-dimensional coordinates (latitude and longitude).
    # The data are temperature (in degrees Fahrenheit), pressure (in Mbars), 
    # and dew point (in degrees Fahrenheit).
    loadExampleData("dwt2d_example", "twod_climate_data")
    
    # Create remote tibble objects.
    twod_climate_data <- tbl(con, "twod_climate_data")
    
    # Example 1 - The function outputs a coefficient model table and a meta table.
    td_dwt2d_out <- td_dwt2d_mle(data = twod_climate_data,
                             input.columns = c("temp_f","pressure_mbar","dewpoint_f"),
                             index.columns = c("latitude","longitude"),
                             wavelet = "db2",
                             level = 2,
                             compact.output = TRUE,
                             partition.columns = c("state")
                             )