DelayedSaturatedMMM.new_spend_contributions#

DelayedSaturatedMMM.new_spend_contributions(spend=None, one_time=True, spend_leading_up=None, prior=False, original_scale=True, **sample_posterior_predictive_kwargs)[source]#

Return the upcoming contributions for a given spend.

The spend can be one time or constant over the period. The spend leading up to the period can also be specified in order account for the lagged effect of the spend.

Parameters:
  • spend (np.ndarray, optional) – Array of spend for each channel. If None, the average spend for each channel is used, by default None.

  • one_time (bool, optional) – Whether the spends for each channel are only at the start of the period. If True, all spends after the initial spend are zero. If False, all spends after the initial spend are the same as the initial spend. By default True.

  • spend_leading_up (np.array, optional) – Array of spend for each channel leading up to the spend, by default None or 0 for each channel. Use this parameter to account for the lagged effect of the spend.

  • prior (bool, optional) – Whether to use the prior or posterior, by default False (posterior)

  • **sample_posterior_predictive_kwargs – Additional keyword arguments passed to pm.sample_posterior_predictive

Returns:

Upcoming contributions for each channel

Return type:

DataArray

Examples

Channel contributions from 1 unit on each channel only once.

n_channels = len(model.channel_columns)
spend = np.ones(n_channels)
new_spend_contributions = model.new_spend_contributions(spend=spend)

Channel contributions from continuously spending 1 unit on each channel.

n_channels = len(model.channel_columns)
spend = np.ones(n_channels)
new_spend_contributions = model.new_spend_contributions(spend=spend, one_time=False)

Channel contributions from 1 unit on each channel only once but with 1 unit leading up to the spend.

n_channels = len(model.channel_columns)
spend = np.ones(n_channels)
spend_leading_up = np.ones(n_channels)
new_spend_contributions = model.new_spend_contributions(spend=spend, spend_leading_up=spend_leading_up)