LogSaturation#
- class pymc_marketing.mmm.components.saturation.LogSaturation(priors=None, prefix=None)[source]#
Logarithmic saturation for log-log models.
Applies \(\beta \, \log(1 + x)\) to the raw (unscaled) channel input, mapping spend through a concave logarithmic curve with diminishing returns.
When combined with
link="log"in the MMM, the model becomes a log-log specification and \(\beta\) is an approximate elasticity – the percentage change in the response per one percent change in spend. For this interpretation to hold, the channel input must not be rescaled: an elasticity is dimensionless, so dividing spend by an arbitrarychannel_scalewould change \(\beta\) (because \(\log(1 + x)\) is not invariant under multiplicative rescaling of \(x\)). This class therefore setsrequires_unscaled_inputtoTrue, which makes the MMM feed raw spend to the saturation and forcechannel_scale = 1for the affected channels.log(1 + x)(rather thanlog(x)) is used so that the transform is finite atx = 0– common for paused or cold-start channels – while remaining numerically indistinguishable fromlog(x)once spend is large, where the elasticity interpretation is exact in the limit \(\partial \log y / \partial \log x \to \beta\).(
Source code,png,hires.png,pdf)
Methods
LogSaturation.__init__([priors, prefix])LogSaturation.apply(x, *[, core_dim, idx])Call within a model context.
LogSaturation.from_dict(data)Reconstruct a saturation transformation from a dict.
LogSaturation.function(x, beta, *[, dim])Logarithmic saturation function: beta * log(1 + x).
LogSaturation.plot_curve(curve[, n_samples, ...])Plot curve HDI and samples.
LogSaturation.plot_curve_hdi(curve[, ...])Plot the HDI of the curve.
LogSaturation.plot_curve_samples(curve[, n, ...])Plot samples from the curve.
LogSaturation.sample_curve([parameters, ...])Sample the curve of the saturation transformation given parameters.
LogSaturation.sample_prior([coords])Sample the priors for the transformation.
Set the dims for all priors.
LogSaturation.to_dict([_orig])Convert the transformation to a dictionary.
LogSaturation.update_priors(priors)Update the priors for a function after initialization.
Return a copy with default prior dims (dims=None) set to
dimsinstead.Return a copy with updated priors.
Attributes
combined_dimsGet the combined dims for all the parameters.
default_priorsfunction_priorsGet the priors for the function.
model_configMapping from variable name to prior for the model.
prefixpriorsGet the priors for the function.
requires_unscaled_inputWhether the saturation must receive raw (unscaled) channel inputs.
variable_mappingMapping from parameter name to variable name in the model.