TanhSaturationBaselined#

class pymc_marketing.mmm.components.saturation.TanhSaturationBaselined(priors=None, prefix=None)[source]#

Wrapper around tanh saturation function.

Multiplies pymc_marketing.mmm.transformers.tanh_saturation_baselined() by an extra scaling parameter beta so the response can reach an asymptote other than the gain-implied one.

Parameters:
x0tensor

Reference point on the input scale, as in tanh_saturation_baselined(). Default prior: Prior("HalfNormal", sigma=1).

gaintensor

Value of the curve at x0 divided by x0 (the ROAS at the baseline). Default prior: Prior("HalfNormal", sigma=1).

rtensor

Overspend fraction, the ratio of the response at x0 to the saturation level. Default prior: Prior("HalfNormal", sigma=1).

betatensor

Scaling factor applied to the baselined-tanh response (multiplies the gain-implied asymptote gain * x0 / r). Default prior: Prior("HalfNormal", sigma=1).

.. plot::
context:

close-figs

import matplotlib.pyplot as plt import numpy as np from pymc_marketing.mmm import TanhSaturationBaselined

rng = np.random.default_rng(0)

adstock = TanhSaturationBaselined() prior = adstock.sample_prior(random_seed=rng) curve = adstock.sample_curve(prior) adstock.plot_curve(curve, random_seed=rng) plt.show()

Methods

TanhSaturationBaselined.__init__([priors, ...])

TanhSaturationBaselined.apply(x, *[, dims, ...])

Call within a model context.

TanhSaturationBaselined.from_dict(data)

Reconstruct a saturation transformation from a dict.

TanhSaturationBaselined.function(x, x0, ...)

Tanh saturation function.

TanhSaturationBaselined.plot_curve(curve[, ...])

Plot curve HDI and samples.

TanhSaturationBaselined.plot_curve_hdi(curve)

Plot the HDI of the curve.

TanhSaturationBaselined.plot_curve_samples(curve)

Plot samples from the curve.

TanhSaturationBaselined.sample_curve([...])

Sample the curve of the saturation transformation given parameters.

TanhSaturationBaselined.sample_prior([coords])

Sample the priors for the transformation.

TanhSaturationBaselined.set_dims_for_all_priors(dims)

Set the dims for all priors.

TanhSaturationBaselined.to_dict([_orig])

Convert the transformation to a dictionary.

TanhSaturationBaselined.update_priors(priors)

Update the priors for a function after initialization.

TanhSaturationBaselined.with_default_prior_dims(dims)

Return a copy with default prior dims (dims=None) set to dims instead.

TanhSaturationBaselined.with_updated_priors(priors)

Return a copy with updated priors.

Attributes

combined_dims

Get the combined dims for all the parameters.

default_priors

function_priors

Get the priors for the function.

model_config

Mapping from variable name to prior for the model.

prefix

priors

Get the priors for the function.

variable_mapping

Mapping from parameter name to variable name in the model.