Description
The Attribution (td_attribution_mle
) function is used in web page
analysis, where it lets companies assign weights to pages before certain
events, such as buying a product.
The function calculates attributions with a choice of distribution
models and has two versions:
Multiple-input: Accepts one or more input tables and gets many parameters from other dimension tables.
Single-input: Accepts only one input table and gets all parameters from argments.
Note: This function is only available when tdplyr is connected to Vantage 1.1 or later versions.
Usage
td_attribution_mle ( data = NULL, data.optional = NULL, conversion.events = NULL, excluding.data = NULL, optional.data = NULL, model1.type = NULL, model2.type = NULL, model1.name = NULL, model2.name = NULL, event.column = NULL, timestamp.column = NULL, window.size = NULL, conversion.data = NULL, optional.events = NULL, exclude.events = NULL, data.sequence.column = NULL, data.optional.sequence.column = NULL, conversion.data.sequence.column = NULL, excluding.data.sequence.column = NULL, optional.data.sequence.column = NULL, model1.type.sequence.column = NULL, model2.type.sequence.column = NULL, data.partition.column = NULL, data.optional.partition.column = NULL, data.order.column = NULL, data.optional.order.column = NULL, conversion.data.order.column = NULL, excluding.data.order.column = NULL, optional.data.order.column = NULL, model1.type.order.column = NULL, model2.type.order.column = NULL )
Arguments
data |
Required Argument. |
data.partition.column |
Required Argument. |
data.order.column |
Required Argument. |
data.optional |
Optional Argument. |
data.optional.partition.column |
Optional Argument. Required if "data.optional" is specified. |
data.optional.order.column |
Optional Argument. |
conversion.events |
Optional Argument. "conversion.events" is a required argument if
"conversion.data" is not provided. |
excluding.data |
Optional Argument. |
excluding.data.order.column |
Optional Argument. |
optional.data |
Optional Argument. |
optional.data.order.column |
Optional Argument. |
model1.type |
Optional Argument."model1.type" is a required argument if
"model1.name" is not provided. |
model1.type.order.column |
Optional Argument. |
model2.type |
Optional Argument. |
model2.type.order.column |
Optional Argument. |
model1.name |
Optional Argument."model1.name" is a required argument if "model1.type"
is not provided. |
model2.name |
Optional Argument. |
event.column |
Required Argument. |
timestamp.column |
Required Argument. |
window.size |
Required Argument.
Types: character |
conversion.data |
Optional Argument."conversion.data" is a required argument if
"conversion.events" is not provided. |
conversion.data.order.column |
Optional Argument. |
optional.events |
Optional Argument. |
exclude.events |
Optional Argument. |
data.sequence.column |
Optional Argument. |
data.optional.sequence.column |
Optional Argument. |
conversion.data.sequence.column |
Optional Argument. |
excluding.data.sequence.column |
Optional Argument. |
optional.data.sequence.column |
Optional Argument. |
model1.type.sequence.column |
Optional Argument. |
model2.type.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_attribution_mle" which is a
named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator
using name: result.
Note
-
The Multiple-input Attribution takes data from multiple tbl_teradata ("data.optional", "conversion.data", "excluding.data", "optional.data", "model1.type" and "model2.type").
The arguments "data.optional", "conversion.data", "excluding.data", "optional.data", "model1.type" and "model2.type" should be mentioned together and should not be used with arguments "conversion.events", "model1.name", "optional.events", "exclude.events" and "model2.name".
For example,
attribution <- Attribution(data = < table | view | (query) >,
data.partition.column = 'partition_column',
data.order.column = 'order_column',
data.optional = < table | view | (query) >,
conversion.data = < table | view | (query) >,
excluding.data = < table | view | (query) >,
optional.data = < table | view | (query) >,
model1.type = < table | view | (query) >,
model2.type = < table | view | (query) >,
event.column = 'event_column',
timestamp.column = 'timestamp_column',
window.size = 'rows:K | seconds:K | rows:K&seconds:K'
) -
The Single-input Attribution takes data from single tbl_teradata ("data") and parameters come from arguments ("conversion.events", "model1.name", "optional.events", "exclude.events" and "model2.name"), not input tbl_teradata.
The arguments "conversion.events", "model1.name", "optional.events", "exclude.events" and "model2.name" should be used together and should not be used with arguments "data.optional", "conversion.data", "excluding.data", "optional.data", "model1.type" and "model2.type".
For example,
attribution <- Attribution(data = < table | view | (query) >,
conversion.events = c('conversion_event', ...),
timestamp.column = ”timestamp_column”,
model1.name = c('type', 'K' | 'EVENT:WEIGHT:MODEL:PARAMETERS', ...),
model2.name = c('type', 'K' | 'EVENT:WEIGHT:MODEL:PARAMETERS', ...),
event.column = "event_column"
window.size = 'rows:K | seconds:K | rows:K&seconds:K',
optional.events = c("organicsearch", "direct", "referral"),
data.order.column = 'order_by_column'
)
Examples
# Get the current context/connection con <- td_get_context()$connection # Load the data to run the example loadExampleData("attribution_example", "attribution_sample_table", "attribution_sample_table1", "attribution_sample_table2", "conversion_event_table", "optional_event_table", "model1_table", "model2_table", "excluding_event_table") # Create remote tibble objects. attribution_sample_table <- tbl(con, "attribution_sample_table") 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") excluding_event_table <- tbl(con, "excluding_event_table") # Example 1 - One Regular Model, Multiple Optional Models. # This example specifes one distribution model for regular events # and one distribution model for each type of optional event. attribution_out1 <- td_attribution_mle(data = attribution_sample_table, data.partition.column = 'user_id', data.order.column = 'time_stamp', event.column = 'event', timestamp.column = 'time_stamp', window.size = 'rows:10&seconds:20', exclude.events = 'Email', conversion.events = c('SocialNetwork','PaidSearch'), model1.name = c('SEGMENT_ROWS', '3:0.5:EXPONENTIAL:0.5,ROW','4:0.3:WEIGHTED:0.4,0.3,0.2,0.1', '3:0.2:FIRST_CLICK:NA'), model2.name = c('SEGMENT_SECONDS','6:0.5:UNIFORM:NA','8:0.3:LAST_CLICK:NA','6:0.2:FIRST_CLICK:NA'), optional.events = c('OrganicSearch','Direct','Referral') ) # Example 2 - Multiple Regular Models, One Optional Model. # This example specifes one distribution model for each type of regular # event and one distribution model for optional events.< attribution_out2 <- td_attribution_mle(data = attribution_sample_table, data.partition.column = 'user_id', conversion.events = c('SocialNetwork','PaidSearch'), timestamp.column = 'time_stamp', model1.name = c('EVENT_REGULAR', 'email:0.19:LAST_CLICK:NA','impression:0.81:UNIFORM:NA'), model2.name = c('EVENT_OPTIONAL', 'ALL:1:EXPONENTIAL:0.5,ROW'), event.column = 'event', window.size = 'rows:10&seconds:20', optional.events = c('OrganicSearch','Direct','Referral'), data.order.column = 'time_stamp' ) # Example 3 - # This example uses Dynamic Weighted Distribution Models Input. attribution_out3 <- td_attribution_mle(data = attribution_sample_table, data.partition.column = 'user_id', conversion.events = c('SocialNetwork','PaidSearch'), timestamp.column = 'time_stamp', model1.name = c('EVENT_REGULAR', 'email:0.19:LAST_CLICK:NA','impression:0.81:WEIGHTED:0.4,0.3,0.2,0.1'), model2.name = c('EVENT_OPTIONAL', 'ALL:1:WEIGHTED:0.4,0.3,0.2,0.1'), event.column = 'event', window.size = 'rows:10&seconds:20', optional.events = c('OrganicSearch','Direct','Referral'), data.order.column = 'time_stamp' ) # Example 4 - This example uses Window Models. attribution_out4 <- td_attribution_mle(data = attribution_sample_table, data.partition.column = 'user_id', conversion.events = c('SocialNetwork','PaidSearch'), timestamp.column = 'time_stamp', model1.name = c('SEGMENT_ROWS','3:0.5:EXPONENTIAL:0.5,ROW','4:0.3:WEIGHTED:0.4,0.3,0.2,0.1','3:0.2:FIRST_CLICK:NA'), model2.name = c('SEGMENT_SECONDS', '6:0.5:UNIFORM:NA', '8:0.3:LAST_CLICK:NA','6:0.2:FIRST_CLICK:NA'), event.column = 'event', window.size = 'rows:10&seconds:20', optional.events = c('OrganicSearch','Direct','Referral'), exclude.events = 'Email', data.order.column = 'time_stamp' ) # Example 5 - This example uses Single-Window Model. attribution_out5 <- td_attribution_mle(data = attribution_sample_table, data.partition.column = 'user_id', conversion.events = c('SocialNetwork','PaidSearch'), timestamp.column = 'time_stamp', model1.name = c('SIMPLE', 'UNIFORM:NA'), event.column = 'event', window.size = 'rows:10&seconds:20', exclude.events = 'Email', data.order.column = 'time_stamp' ) # Example 6 - This example uses Unused Segment Windows. attribution_out6 <- td_attribution_mle(data = attribution_sample_table, data.partition.column = 'user_id', conversion.events = c('SocialNetwork','PaidSearch'), timestamp.column = 'time_stamp', model1.name = c('SEGMENT_ROWS','3:0.5:EXPONENTIAL:0.5,ROW','4:0.3:WEIGHTED:0.4,0.3,0.2,0.1','3:0.2:FIRST_CLICK:NA'), model2.name = c('SEGMENT_SECONDS','6:0.5:UNIFORM:NA','8:0.3:LAST_CLICK:NA', '6:0.2:FIRST_CLICK:NA'), event.column = 'event', window.size = 'rows:10&seconds:20', exclude.events = 'Email', data.order.column = 'time_stamp' ) # Example 7 - This example uses Multiple Inputs which takes data # and parameters from multiple tables and outputs attributions. attribution_out7 <- td_attribution_mle(data = attribution_sample_table1, data.partition.column = 'user_id', data.optional = attribution_sample_table2, data.optional.partition.column = 'user_id', data.order.column = 'time_stamp', conversion.data = conversion_event_table, excluding.data = excluding_event_table, optional.data = optional_event_table, model1.type = model1_table, model2.type = model2_table, event.column = 'event', timestamp.column = 'time_stamp', window.size = 'rows:10&seconds:20' )