Set the max_lag parameter

The Meridian model allows for media at time \(t\) to affect the KPI at times \(t, t + 1, \dots , t + L\) where the integer \(L\) is a hyperparameter set by the user using the max_lag parameter of ModelSpec. Media can potentially have a long effect that goes beyond max_lag. However, Meridian assumes lagged effects decay monotonically toward zero and these effects eventually become small. For practical reasons, we truncate the effect at the max_lag value.

max_lag tradeoffs

Smaller values of max_lag generally lead to improved model convergence and faster model model runtimes. Smaller values of max_lag can also reduce model variance: with large max_lag values, the amount of data available is often insufficient for Meridian models to precisely estimate lagged effects, increasing model variance. On the other hand, larger values of max_lag increase the duration of lagged effects which can be beneficial for models that expect long term effects.

Increasing max_lag doesn't necessarily mean that ROI estimates will also increase. One reason for this is because if the media at time \(t\) can affect the KPI at time \(t+L\), this can take away from the effect of media at times \(t+1, \dots , t+L\) on the KPI at time \(t+L\).

Practical advice for setting max_lag

The two adstock decay functions offered in Meridian, geometric and binomial, balance max_lag tradeoffs differently.

When using geometric decay

With geometric decay, setting max_lag in the 2-10 range leads to a good balance of modeling the lagged effects of media while minimizing the potential disadvantages of a max lag that is too large. The geometric decay curve decays to zero very quickly for most values of \(\alpha\), so setting max_lag to a very large value has a negligible effect on the model likelihood.

When using binomial decay

With binomial decay, however, the curve is a function of the max lag: it is stretched to cover the effect window as its x-intercept is always at \(L + 1\). As a result, the concern of diminishing returns no longer applies and you can use binomial decay with a larger value of max_lag. However, convergence and model runtimes can still become worse with increasing max_lag. This tension should be balanced with potential benefits of increasing max_lag, and we recommend selecting a max_lag value in the 4-20 range in this case.

When using a combination of geometric and binomial

Deciding on increasing the value of max_lag can be complicated if you are using different decay functions for different channels. If you are predominantly using one function with a small number of exceptions we recommend following the recommendation of the predominant function. If you are using a more balanced mix, we recommend selecting a max_lag in the 4-20 range. This gives a good balance of binomial lagged effect modeling while avoiding the drawbacks of using geometric with a large max_lag.

Adstock Decay Function Max Lag Recommendation
Geometric 2-10 time periods.
Binomial 4-20 time periods.
Geometric/Binomial Combination 4-20 time periods.

For additional details on the decay functions and alpha prior, see Set the adstock_decay_spec parameter.