Teradata Package for R Function Reference | 17.20 - Attribution - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
ft:locale
en-US
ft:lastEdition
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
Product Category
Teradata Vantage

Attribution

Description

The td_attribution_sqle() function is used in web page analysis, where it lets companies assign weights to pages before certain events, such as buying a product.

Usage

  td_attribution_sqle (
      data = NULL,
      data.optional = NULL,
      data.optional2 = NULL,
      data.optional3 = NULL,
      data.optional4 = NULL,
      conversion.data = NULL,
      excluding.data = NULL,
      optional.data = NULL,
      model1.type = NULL,
      model2.type = NULL,
      event.column = NULL,
      timestamp.column = NULL,
      window.size = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

data.optional

Optional Argument.
Specifies the click stream data, which the function uses to compute attributions.
Types: tbl_teradata

data.optional2

Optional Argument.
Specifies the click stream data, which the function uses to compute attributions.
Types: tbl_teradata

data.optional3

Optional Argument.
Specifies the click stream data, which the function uses to compute attributions.
Types: tbl_teradata

data.optional4

Optional Argument.
Specifies the click stream data, which the function uses to compute attributions.
Types: tbl_teradata

conversion.data

Required Argument.
Specifies one varchar column (conversion_events) containing conversion event values.
Types: tbl_teradata

excluding.data

Optional Argument.
Specifies one varchar column (excluding_events) containing excluding cause event values.
Types: tbl_teradata

optional.data

Optional Argument.
Specifies one varchar column (optional_events) containing optional cause event values.
Types: tbl_teradata

model1.type

Required Argument.
Specifies the type and specification of the first model.
For example:

--------------------------
id model
--------------------------
0 SEGMENT_SECONDS
1 6:0.5:UNIFORM:NA
2 8:0.3:LAST_CLICK:NA
3 6:0.2:FIRST_CLICK:NA
--------------------------

Types: tbl_teradata

model2.type

Optional Argument.
Specifies the type and distributions of the second model.
For example:

-----------------------------------
id model
-----------------------------------
0 SEGMENT_ROWS
1 3:0.5:EXPONENTIAL:0.5,SECOND
2 4:0.3:WEIGHTED:0.4,0.3,0.2,0.1
3 3:0.2:FIRST_CLICK:NA
-------------------------------------

Types: tbl_teradata

event.column

Required Argument.
Specifies the name of the input column that contains the clickstream events.
Types: character

timestamp.column

Required Argument.
Specifies the name of the input column that contains the timestamps of the clickstream events.
Types: character

window.size

Required Argument.
Specifies how to determine the maximum window size for the attribution calculation: rows:K: Consider the maximum number of events to be attributed, excluding events of types specified in excluding_event_table, which means assigning attributions to at most K effective events before the current impact event.seconds:K:
Consider the maximum time difference between the current impact event and the earliest effective event to be attributed. rows:K&seconds:K2:
Consider both constraints and comply with the stricter one.
Types: character

...

Specifies the generic keyword arguments SQLE functions accept.
Below are the generic keyword arguments:

persist:
Optional Argument.
Specifies whether to persist the results of the function in a table or
not. When set to TRUE, results are persisted in a table; otherwise, results are garbage collected at the end of the session.
Default Value: FALSE
Types: logical

volatile:
Optional Argument.
Specifies whether to put the results of the function in a volatile table
or not. When set to TRUE, results are stored in a volatile table, otherwise not.
Default Value: FALSE
Types: logical

Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:

  • "<input.data.arg.name>.partition.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.hash.column" accepts character OR vector of Strings (character) (Strings)

  • "<input.data.arg.name>.order.column" accepts character OR vector of Strings (character) (Strings)

  • "local.order.<input.data.arg.name>" accepts logical

Note:
These generic arguments are supported by tdplyr if the underlying SQLE function supports it, else an exception is raised.

Value

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

Examples

  
    
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load the data to run the example
    loadExampleData("attribution_example", "attribution_sample_table1",
                    "attribution_sample_table2" , "conversion_event_table",
                    "optional_event_table", "model1_table", "model2_table")
    
    # Create tbl_teradata object
    attribution_sample_table1 <- tbl(con, "attribution_sample_table1")
    attribution_sample_table2 <- tbl(con, "attribution_sample_table2")
    conversion_event_table <- tbl(con, "conversion_event_table")
    optional_event_table <- tbl(con, "optional_event_table")
    model1_table <- tbl(con, "model1_table")
    model2_table <- tbl(con, "model2_table")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Assign attribution weights to events and channels.
    attribution_out <- td_attribution_sqle(data=attribution_sample_table1,
                                           data.partition.column="user_id",
                                           data.order.column="time_stamp",
                                           data.optional=attribution_sample_table2,
                                           data.optional.partition.column='user_id',
                                           data.optional.order.column='time_stamp',
                                           event.column="event",
                                           conversion.data=conversion_event_table,
                                           optional.data=optional_event_table,
                                           timestamp.column = "time_stamp",
                                           window.size = "rows:10&seconds:20",
                                           model1.type=model1_table,
                                           model2.type=model2_table)
    
    # Print the results.
    print(attribution_out$result)