adstock#

Adstock transformations for MMM.

Each of these transformations is a subclass of pymc_marketing.mmm.components.adstock.AdstockTransformation and defines a function that takes a time series and returns the adstocked version of it. The parameters of the function are the parameters of the adstock transformation.

Examples#

Create a new adstock transformation:

from pymc_marketing.mmm import AdstockTransformation
from pymc_marketing.prior import Prior

class MyAdstock(AdstockTransformation):
    lookup_name: str = "my_adstock"

    def function(self, x, alpha):
        return x * alpha

    default_priors = {"alpha": Prior("HalfNormal", sigma=1)}

Plot the default priors for an adstock transformation:

from pymc_marketing.mmm import GeometricAdstock

import matplotlib.pyplot as plt

adstock = GeometricAdstock(l_max=15)
prior = adstock.sample_prior()
curve = adstock.sample_curve(prior)
adstock.plot_curve(curve)
plt.show()

Functions

adstock_from_dict(data)

Create an adstock transformation from a dictionary.

Classes

AdstockTransformation([l_max, normalize, ...])

Subclass for all adstock functions.

DelayedAdstock([l_max, normalize, mode, ...])

Wrapper around delayed adstock function.

GeometricAdstock([l_max, normalize, mode, ...])

Wrapper around geometric adstock function.

WeibullCDFAdstock([l_max, normalize, mode, ...])

Wrapper around weibull adstock with CDF function.

WeibullPDFAdstock([l_max, normalize, mode, ...])

Wrapper around weibull adstock with PDF function.