kernel_trailing_lags#

pymc_marketing.mmm.incrementality.kernel_trailing_lags(l_max, mode)[source]#

Lags after a spend date that the adstock kernel itself reaches.

Follows the padding in batched_convolution(): After places the kernel’s l_max weights on lags 0 .. l_max - 1, Overlap centres them so l_max // 2 fall after the spend date, and Before places them all on or before it. build() ends the Overlap and Before evaluation ranges the same way; its windowed After range keeps one date of slack past the last lag.

The one definition of how far a plain kernel carries. Incrementality passes it to measure() as the floor under the measured horizon, and under full-axis evaluation, where no horizon was measured, uses it as a lower bound on how far a period’s carryover runs.

Parameters:
  • l_max (int) – The adstock’s number of kernel weights.

  • mode (ConvMode) – The adstock’s convolution mode.

Return type:

int

Returns:

The last lag the kernel places weight on, 0 for Before.

Raises:

ValueError – For an unknown mode.

Examples

from pymc_marketing.mmm.incrementality import kernel_trailing_lags
from pymc_marketing.mmm.transformers import ConvMode

kernel_trailing_lags(8, ConvMode.After)  # 7
kernel_trailing_lags(8, ConvMode.Overlap)  # 4
kernel_trailing_lags(8, ConvMode.Before)  # 0