LogLinkSpec#

class pymc_marketing.mmm.link.LogLinkSpec[source]#

Log link: median(y) = exp(mu) * target_scale.

The likelihood is LogNormal(mu, sigma), so exp(mu) is the conditional median of the response, not its mean (E[y] = exp(mu + sigma**2 / 2) * target_scale). All predictions and counterfactual contributions are computed on this median scale; use the central_tendency="mean" option (which applies mean_correction(), the exp(sigma**2 / 2) factor) to obtain mean-scale quantities.

Methods

LogLinkSpec.__init__(*args, **kwargs)

LogLinkSpec.create_media_contribution_deterministic(...)

Register counterfactual total_media_contribution_original_scale and {output_var}_original_scale.

LogLinkSpec.default_intercept(dims)

Return Normal(0, 5) intercept prior (wider for log-scale).

LogLinkSpec.default_likelihood(dims)

Return LogNormal likelihood prior.

LogLinkSpec.inverse_link(mu)

Return exp(mu) (the conditional median of the LogNormal response).

LogLinkSpec.mean_correction(posterior[, ...])

Return exp(sigma**2 / 2), the LogNormal mean/median ratio.

LogLinkSpec.original_scale_transform(...)

Return exp(variable) * target_scale.

LogLinkSpec.validate_likelihood_compatibility(...)

Raise if likelihood is incompatible with link.

LogLinkSpec.validate_target(y)

Raise ValueError if y contains non-positive values.

Attributes

link