Add Optional Delayed Adstock Transformation for More Flexible Carryover Effects #658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #385
This PR implements an optional delayed adstock function to address the feature request for more flexible carryover effects, especially when dealing with channels that exhibit longer conversion periods. In my experience with travel, real estate, and other high-involvement purchases, the impact of marketing spend can peak days or even weeks after the initial touchpoint.
Previous workarounds, such as adjusting the
max_lag
parameter or shifting the input data manually, have proven too inflexible and ad hoc.Key Changes:
ModelSpec Modification:
Added a new field
adstock
(defaulting to"geometric"
) in theModelSpec
class. When set to"delayed"
, the model will switch to using the delayed adstock transformation.Users can now activate delayed adstock by configuring the model as follows:
Delayed Adstock Implementation:
Introduced a new transformer class,
DelayedAdstockTransformer
, which computes adstock weights according to the following formula:where theta is the delay parameter. This formulation is proposed by Bayesian Methods for Media Mix Modeling with Carryover and Shape Effects.
Prior Distributions:
theta_m
,theta_rf
, etc.) in thePriorDistribution
class.theta
is assigned a Uniform prior over the range[0, max_lag - 1]
. This choice is noninformative and allows the model to learn the appropriate delay from data. In our reading (e.g., Bayesian Methods for Media Mix Modeling with Carryover and Shape Effects, section 2.1), a uniform prior for delay is suitable when no strong prior assumptions are available.