The effects of media execution on KPI are governed by two mechanisms: a lagged
effect and a saturation effect. Lagged effects refer to the way in which the
effect of a media channel on KPI has a lagged effect that tapers off slowly
over time. Saturation effects refer to diminishing marginal returns with
increased media execution.

## Adstock function

Meridian's model architecture is designed to capture lagged effects
through an Adstock function.

In the Adstock function, the cumulative media effect at time \\(t\\) is a
weighted average of media execution at times \\(t, t-1, ..., t-L\\) with weights
determined by a weight function \\(w(s; \\alpha)\\). Here, \\(L\\) is the maximum
duration of the lagged effect.

Meridian offers the Adstock function with two weight functions
\\(w(s; \\alpha)\\): `geometric` and `binomial`. For more details on the
functions, see [Set the adstock_decay_spec
parameter](https://developers.google.com/meridian/docs/advanced-modeling/set-adstock-decay-spec-parameter).
For more information on the Adstock function, see [A Hierarchical Bayesian
Approach to Improve Media Mix Models Using Category
Data](https://research.google/pubs/a-hierarchical-bayesian-approach-to-improve-media-mix-models-using-category-data/)
and [Bayesian Methods for Media Mix Modeling with Carryover and Shape
Effects](https://research.google/pubs/bayesian-methods-for-media-mix-modeling-with-carryover-and-shape-effects/).

> [!NOTE]
> **Note:** For a quick summary of how these media transformation parameters ($\\alpha$, $ec$, $slope$, $L$) relate to the rest of the model's learned coefficients, check out the [Media transformation parameters](https://developers.google.com/meridian/docs/basics/math-notation#model-parameters) reference.

The Adstock function is defined as follows:
$$ \\text{Adstock}(x_t, x_{t-1}, \\cdots, x_{t-L};\\ \\alpha)\\ = \\dfrac{\\sum\\limits_{s=0}\^L\\ w(s; \\alpha)x_{t-s}} {\\sum\\limits _{s=0}\^L\\ w(s; \\alpha)} $$

where:

- \\(w(s; \\alpha) \\) is the [decay function](https://developers.google.com/meridian/docs/advanced-modeling/set-adstock-decay-spec-parameter)

- \\(x_s \\geq 0\\) is media execution at time \\(s\\)

- \\(\\alpha\\ \\in\\ \[0, 1\]\\) is the decay parameter

- \\(L\\) is the maximum lag duration.

## Hill function

Meridian's model architecture is designed to capture saturation effects
through a Hill function.

It is intuitive that as spending on a given media channel within any given
time period increases, you eventually see diminishing marginal returns, for
example, saturation. Meridian models this
saturation effect through a two-parameter function known as the Hill function.

The Hill function is defined as follows:
$$ \\text{Hill}(x; ec, \\text{slope}) = \\frac{1}{1+\\left( \\frac{x}{ec} \\right)\^ {- \\text{slope}}} $$

where:

- \\(x \\geq 0\\)

- \\(ec \> 0\\) is the half saturation point, meaning that \\(\\text{Hill}(x=ec;
  ec, \\text{slope}) = 0.5\\)

- \\(\\text{slope} \> 0\\) is a parameter that controls the function shape:

  - \\(\\text{slope} \\leq 1\\) corresponds to a concave shape
  - \\(\\text{slope} \> 1\\) corresponds to an *S* shaped function that is convex for \\( x \< ec \\) and concave for \\( x \> ec \\).

> [!NOTE]
> **Note:** Meridian's [default prior](https://developers.google.com/meridian/docs/advanced-modeling/default-prior-distributions#slope_m_and_slope_om) for `slope_m` and `slope_om` assumes a concave shape. *S*-shaped curves can cause issues for budget optimization due to their convexity and may lead to convergence issues.

**Important:** The model's estimation of the Hill function parameters is based
on the observed range of media data. The fitted response curve can be
extrapolated outside this range, but results based on extrapolation should be
interpreted with an appropriate level of caution.

The Hill function can be applied either before or after the Adstock
transformation, depending on the boolean `hill_before_adstock` argument of the
`ModelSpec`. The default setting is `hill_before_adstock = False`, which makes
the media effect of channel \\(m\\) within geo \\(g\\) and time period \\(t\\)
equal to \\(\\beta_{g,m} \\text{Hill}(\\text{Adstock}(x_t,x_{t-1},\\cdots,x_{t-L};\\
\\alpha_m) ;ec_m, \\text{slope}_m)\\).