resolve_channel_dependent_effects#
- pymc_marketing.mmm.spend_reach.resolve_channel_dependent_effects(model)[source]#
Find the
mu_effectsa spend counterfactual reaches.The counterfactual perturbs
channel_data, so any effect withchannel_dataamong its ancestors carries part of the resulting change in the linear predictor and has to be evaluated alongsidechannel_contribution. A funnel mediator is the motivating case: upper-funnel spend moves latent demand, demand moves lower-funnel spend, and only then does the target respond.Effects that do not depend on
channel_data– a linear trend, an event window, seasonality – are part of the baseline. They cancel in the difference and are skipped without consulting their spec.An effect whose contribution cannot be located at all is not an error here. Duck-typed effects are a documented pattern (see the module docstring of
additive_effect) and need not carry acontribution_var_name; aMuEffectbuilt without aprefixraisesNotImplementedErrorrather than returning one. Neither says anything about whether spend reaches the effect, so the failure is deferred: such an effect is left unaccounted, andSpendProbe.assert_increment_is_complete()raises only if a spend path really does escape through it. Raising eagerly instead would break every model that merely owns such an effect. This is distinct from anAttributeErrorraised inside a presentcontribution_var_name(for example a property that touches a missingselfattribute): that is a bug in the effect, not an absent attribute, and propagates instead of being swallowed.- Parameters:
- model
MMM The fitted model whose
mu_effectsare being resolved.
- model
- Returns:
tupleofChannelDependentEffectOne entry per effect to include, in
mu_effectsorder. Empty for a model with no channel-dependent effects, which is the separable case the incrementality module was originally written for.
- Raises:
NotImplementedErrorIf an effect is known to depend on
channel_databut has not opted in viaincrementality_spec(). A refusal to guess: the alternative is dropping a real part of the increment and reporting the remainder as if it were the whole.ValueErrorIf an included effect’s contribution carries dimensions outside
("date", *model.dims).AttributeErrorPropagated unchanged if an effect’s
contribution_var_nameproperty is present but raises while computing its value, rather than being mistaken for an absent attribute.