Why does adstock.sample_curve measure periodicity as np.arange(0, self.l_max)
, while new_spend_contributions measures with np.arange(-self.adstock.l_max, self.adstock.l_max + 1)
So for adstock l_max = 6, when using sample_curve I get 0, 1, 2, 3, 4, 5, but when using new_spend_contributions, I get periods -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6? I would expect the same max period range as my adstock max but it’s one more.
@fountainpen probably need more input from your side.
In short: l_max is the number of nonzero lags; sample_curve omits the trailing zero at +l_max, while new_spend_contributions includes it for symmetry and plotting. If you want them to match, drop the last point when using new_spend_contributions, e.g.: contrib.sel(time_since_spend=slice(-adstock.l_max, adstock.l_max - 1))
. The “one more” you see is that explicit inclusion of the zero-valued boundary at +l_max.
The two methods serve different purposes, so their time axes are built differently, thats it.
l_max in geometric_adstock is defined as “Maximum duration of carryover effect.” Does that mean at l_max the effect is 0? When calculating mmm.adstock.sample_curve
for l_max = 6, at time 5 I get median values ~5e-4. However, when using mmm.new_spend_contributions
I get 0 values for times 5 and 6. Should new spend contributions be non zero at time 5 since the adstock decay still has a positive value at time 5?
# Get baseline (all channels running)
stopped_contributions = mmm.new_spend_contributions(spend=stopped_spend,spend_leading_up=mean_spend,one_time=False,original_scale=True)
stopped_mean = stopped_contributions.mean(dim=['chain', 'draw'])