For media channels with reach and frequency data, there is an opportunity to
optimize the target average ad frequency, in addition to optimizing the budget
allocation across channels. However, just because reach and frequency data is
available for a channel does not necessarily mean that an advertiser has a high
degree of control over the average frequency. Meridian provides the
option to perform budget optimization based on either the optimal average
frequency or the historical average frequency for each channel.

- For each channel where historical average frequency is used, it is assumed
  that the average frequency within each region and time period remains
  constant, regardless of the budget allocation.

- For each channel where frequency optimization is preferred, Meridian
  first solves for the optimal frequency value. This optimization constrains
  the optimal frequency to be equal for all regions and time periods. This
  restriction serves two purposes: first, to obtain a target frequency
  strategy that is more practical to implement, and second, to make the
  optimization routine more tractable. Based on the Meridian model
  specification, it turns out that the optimal frequency does not depend on
  the budget allocation.

In either case, the assumption for any given budget level is that impressions
are allocated according to the historical flighting pattern across geographic
regions and time periods. Suppose that you want to compute a budget optimization
for a set of regions $G$ and time interval \\(\[t_0,t_1\]\\). Let \\(c_i\^{\[RF\]}=
\\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t,i}\^{\[RF\]} \\cdot \\ddot
r_{g,t,i}\^{\[RF\]} \\cdot f_{g,t,i}\^{\[RF\]}\\) be the actual historical budget for
each channel $i$ over the optimization regions and time periods. Denoted is a
proposed budget allocation across all channels as a pair of vectors
\\(b=(b_1,\\ldots b_{N_{RF}})\\) and \\(b\^{\[RF\]}=(b_1\^{\[RF\]}, \\ldots
b_{N_{RF}}\^{\[RF\]})\\), and a proposed set of average frequency targets as
\\(f=\\{f_{g,t,i}\^{\\ast}\\}\\), where \\(f_{g,t,i}\^\* \\geq 1\\ \\forall g,t,i\\). The
asterisk distinguishes the proposed frequency from the historical frequency.

Using the historical flighting pattern, the reach for each geo and time period
is defined as:

\\(\\ddot r_{g,t,i}\^{\\left( b\^{\[RF\]},f \\right)} = \\dfrac{ \\ddot r_{g,t,n}\^{\[RF\]}
f_{g,t,n}\^{\[RF\]} b_i\^{\[RF\]} }{f_{g,t,n}\^\*c_i\^{\[RF\]} }\\) for \\(t \\in
\[t_0-L,t_1\]\\)

and the corresponding transformed media units as:

\\(r_{g,t,n}\^{(b\^{\[RF\]},f)} = L_{g,i}\^{\[RF\]}\\left(\\ddot r_{g,t,i}\^{\[b,f\]}\\right)
= \\dfrac{ r_{g,t,i}\^{\[RF\]} f_{g,t,i}\^{\[RF\]} b_i\^{\[RF\]} }{f_{g,t,i}\^\*c_i\^{\[RF\]}
}\\)

## Optimal frequency

The expected outcome is now a function of the budget vectors \\(b\\) and
\\(b\^{\[RF\]}\\) as well as the target frequencies \\(f\\):
$$ \\begin{multline\*} E(\\text{ExpectedOutcome}(b,b\^{\[RF\]},f)\| \\text{Data}) = \\\\ \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\tau_g\^{(j)} + \\mu_t\^{(j)} + \\sum\\limits_{i=1}\^{N_C} \\gamma_{g,i}\^{\[C\](j)}z_{g,t,i} + \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{\[b\]} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left(b\^{\[RF\]},f\\right)} \\text{Hill} \\Bigl( f_{g,t-s,i}\^\*; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{multline\*} $$

For any given budget allocation and set of target frequencies, the optimal
frequency of the \\(i\^{th}\\) channel is defined as follows:
$$ \\begin{align\*} f_{optimal,i} \&= \\underset{f_i}{\\text{argmax}}\\ E \\left( \\text{ExpectedOutcome} \\left( b, b\^{\[RF\]}, f \\right) \\Big\| \\text{Data} \\right) \\\\ \&= \\underset{f_i}{\\text{argmax}}\\ \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ \\dfrac{ r_{g,t-s,i}\^{\[RF\]} f_{g,t-s,i}\^{\[RF\]} b_i\^{\[RF\]} }{ f_i c_i\^{\[RF\]} } \\text{Hill} \\Bigl( f_i; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\\\ \&= \\underset{f_i}{\\text{argmax}}\\ \\frac{b_i\^{\[RF\]}}{c_i\^{\[RF\]}} \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ \\dfrac{ r_{g,t-s,i}\^{\[RF\]} f_{g,t-s,i}\^{\[RF\]} }{ f_i } \\text{Hill} \\Bigl( f_i; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

\\(b_i\^{\[RF\]}\\) and \\(c_i\^{\[RF\]}\\) factor out of the objective function
completely, so the optimal frequency does not depend on the budget allocation.
As a result, it is possible to solve for the optimal frequencies first, and then
plug in these values to the expected outcome function to optimize the budget
allocation.

## Fixed budget optimization

Consider a fixed budget optimization with total budget \\(C\\). Define the set
of all budget vectors with this total budget as \\(B_C = \\left\\{b, b\^{(rf)}:
\\sum\\limits_{m=1}\^M b_m + \\sum\\limits_{n=1}\^Nb_n\^{(rf)}=C \\right\\}\\).
Meridian provides the option to perform budget optimization based on
either the optimal average frequency or the historical average frequency for
each channel. The quantity being optimized is expected outcome assuming that the
frequency is either optimal or historical frequency, defined as follows:
of all budget vectors with this total budget as \\(B_C = \\left\\{b, b\^{\[RF\]}:
\\sum\\limits_{i=1}\^{N_M} b_i + \\sum\\limits_{i=1}\^{N_{RF}} b_i\^{\[RF\]}=C
\\right\\}\\). Meridian provides the option to perform budget optimization
based on either the optimal average frequency or the historical average
frequency for each channel. The quantity being optimized is expected outcome
assuming that the frequency is either optimal or historical frequency, defined
as follows:

**Expected outcome for optimal frequency:**

\\(EO_ \\text{optimalfreq}\\left(b,b\^{\[RF\]}\\right) = \\sum\\limits_{g \\in G}
\\sum\\limits_{t=t_0}\^{t_1} E\\left( \\overset \\sim Y_{g,t}\^{\\left(\\left\\{
x_{g,t,i}\^{\[b\]}, r_{g,t,i}\^{\[b\^\[RF\],\\text{optimal}\]}, f_{\\text{optimal},i}
\\right\\}\\right)} \\Bigg\| \\left\\{ z_{g,t,i} \\right\\}\\right)\\)

**Expected outcome for historical frequency:**

\\(EO_ \\text{historialfreq}\\left(b,b\^{\[RF\]}\\right) = \\sum\\limits_{g \\in G}
\\sum\\limits_{t=t_0}\^{t_1} E\\left( \\overset \\sim Y_{g,t}\^{\\left(\\left\\{
x_{g,t,m}\^{\[b\]}, r_{g,t,i}\^{\[b\^\[RF\],f\]}, f\^{\[RF\]}_{g,t,i} \\right\\}\\right)}
\\Bigg\| \\left\\{ z_{g,t,i} \\right\\}\\right)\\)

Where \\(f_{\\text{optimal},i}\\) and \\(f_{g,t,i}\\) are predefined properties
representing the optimal frequency and the historical frequency for the \\(i\\)^*th*^

channel, and therefore there are two parameters, \\(b\\) and \\(b\^{\[RF\]}\\).

The actual parameter values are unknown. Meridian estimates the expected
outcome using a posterior distribution. To optimize the budget, the posterior
mean of the expected outcome is utilized as the objective function. The optimal
budget vector is defined as follows.

**Optimal budget allocation when optimal frequency is used:**
$$ \\begin{align\*} b_ \\text{optimal}, b_ \\text{optimal}\^{\[RF\]} = \\underset{b \\in B_C,b\^{\[RF\]} \\in B_C}{\\text{argmax}}\\ \& E \\left\[ EO_ \\text{optimalfreq}\\left( b,b\^{\[RF\]} \\right) \\Big\| \\text{Data} \\right\] \\\\ = \\underset{b \\in B_C,b\^{\[RF\]} \\in B_C}{\\text{argmax}}\\ \& \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{\[b\]} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ \& + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left(b\^{\[RF\]},f_ \\text{optimal} \\right)} \\text{Hill} \\Bigl( f_{\\text{optimal},i}; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

**Optimal budget allocation when historical frequency is used:**
$$ \\begin{align\*} b_ \\text{optimal}, b_ \\text{optimal}\^{\[RF\]} = \\underset{b \\in B_C,b\^{\[RF\]} \\in B_C}{\\text{argmax}}\\ \& E \\left\[ EO_{historicalfreq}\\left( b,b\^{\[RF\]} \\right) \\Big\| Data \\right\] \\\\ = \\underset{b \\in B_C,b\^{\[RF\]} \\in B_C}{\\text{argmax}}\\ \& \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{\[b\]} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ \& + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left( b\^{\[RF\]},f \\right)} \\text{Hill} \\Bigl( f_{g,t-s,}\^{\[RF\]}; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

Where:

- \\(J\\) is defined to be the total number of MCMC posterior draws.
- The \\(j\\)^*th*^ posterior draw of each parameter is denoted with the superscript \\(\^{(j)}\\).

## Flexible budget optimization

For flexible budget optimization, the expected outcome is optimized while
allowing the total budget to vary. The optimization process is subject to
constraints imposed by either the minimal marginal return on investment (ROI) or
the target ROI constraints. Additionally, the optimization considers either the
optimal average frequency or the historical average frequency for each channel.

### Target ROI constraint

When the target ROI is specified, it means Meridian searches over all
budget vectors \\(b=(b_1,\\ldots,b_{N_M})\\) such that the total ROI \\(ROI \\geq
ROI_{target}\\ \\forall i\\), while allowing the total budget
\\(\\sum\\limits_{i=1}\^{N_M} b_i\\) to vary. The optimal budget vector is defined
as follows.

**Optimal budget allocation when optimal frequency is used:**
$$ \\begin{align\*} b_ \\text{optimal}, b_ \\text{optimal}\^{\[RF\]} = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& E \\left\[ EO_ \\text{optimalfreq}\\left( b, b\^{\[RF\]} \\right) \\Big\| \\text{Data} \\right\] \\\\ = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{(b)} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ \& + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left(b\^{\[RF\]},f_ \\text{optimal}\\right)} Hill \\Bigl( f_{\\text{optimal},i}; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

\\( s.t.\\ \\dfrac{ \\sum\\limits_{i=1}\^{N_M} \\text{IncrementalOutcome}_i }{
\\sum\\limits_{i=1}\^{N_M} b_i } \> \\text{ROI}_{target} \\)

**Optimal budget allocation when historical frequency is used:**
$$ \\begin{align\*} b_ \\text{optimal}, b_{\\text{optimal}}\^{\[RF\]} = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& E \\left\[ EO_ \\text{historicalfreq}\\left( b, b\^{\[RF\]} \\right) \\Big\| \\text{Data} \\right\] \\\\ = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{\[b\]} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ \& + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left(b\^{\[RF\]},f\\right)} \\text{Hill} \\Bigl( f_{g,t-s,i}\^{\[RF\]}; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

\\( s.t.\\ \\dfrac{ \\sum\\limits_{i=1}\^{N_M} \\text{IncrementalOutcome}_i }{
\\sum\\limits_{i=1}\^{N_M} b_i } \> \\text{ROI}_{target} \\)

Where the target ROI constraint is applied at the total marketing ROI level, and
not at channel level.

### Minimal mROI constraint

When the minimal marginal ROI is specified, Meridian searches over all
budget vectors \\(b=(b_1, \\ldots, b_{N_M})\\) such that the marginal ROI
\\(mROI_i \\geq mROI_{minimal}\\ \\forall i\\), while allowing the total budget
\\(\\sum\\limits_{i=1}\^{N_M} b_i\\) to vary. The optimal budget vector is defined
as follows:

**Optimal budget allocation when optimal frequency is used:**
$$ \\begin{align\*} b_ \\text{optimal}, b_ \\text{optimal}\^{\[RF\]} = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& E \\left\[ EO_ \\text{optimalfreq}\\left( b, b\^{\[RF\]} \\right) \\Big\| \\text{Data} \\right\] \\\\ = \\underset{b,b\^{\[RF\]}}{\\text{argmax}}\\ \& \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{\[b\]} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ \& + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left(b\^{\[RF\]},f_ \\text{optimal}\\right)} \\text{Hill} \\Bigl( f_{\\text{optimal},i}; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

\\( s.t.\\ \\text{mROI}_i(b_i) \> \\text{mROI}_\\text{minimal}\\ \\forall i \\)

**Optimal budget allocation when historical frequency is used:**
$$ \\begin{align\*} b_\\text{optimal}, b_\\text{optimal}\^{\[RF\]} = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& E \\left\[ EO_\\text{historicalfreq}\\left(b, b\^{\[RF\]} \\right) \\Big\| \\text{Data} \\right\] \\\\ = \\underset{b, b\^{\[RF\]}}{\\text{argmax}}\\ \& \\frac{1}{J} \\sum\\limits_{j=1}\^J \\sum\\limits_{g \\in G} \\sum\\limits_{t=t_0}\^{t_1} u_{g,t}\^{\[Y\]} L_{g,t}\^{\[Y\]-1} \\Biggl( \\sum\\limits_{i=1}\^{N_M} \\beta_{g,i}\^{\[M\](j)} \\text{HillAdstock} \\biggl( \\Bigl\\{ x_{g,t-s,i}\^{\[b\]} \\Bigr\\}_{s=0}\^L; \\alpha_i\^{\[M\](j)}, ec_i\^{\[M\](j)}, \\text{slope}_i\^{\[M\](j)} \\biggr) \\\\ \& + \\sum\\limits_{i=1}\^{N_{RF}} \\beta_{g,i}\^{\[RF\](j)} \\text{Adstock} \\biggl( \\Bigl\\{ r_{g,t-s,i}\^{\\left( b\^{\[RF\]},f \\right)} \\text{Hill} \\Bigl( f_{g,t-s,i}\^{\[RF\]}; ec_i\^{\[RF\](j)}, \\text{slope}_i\^{\[RF\](j)} \\Bigr) \\Bigr\\}_{s=0}\^L \\biggr) \\Biggr) \\end{align\*} $$

\\( s.t.\\ \\text{mROI}_i(b_i) \> \\text{mROI}_{minimal}\\ \\forall i \\)

Where the minimal mROI is applied at channel level and not at the total
marketing level.

## Channel-level spend constraints

Channel-level spend constraints are available for both fixed and flexible budget
optimization to prevent unreasonable optimization outcomes such as putting all
spend into one single channel. The channel-level spend constraint is defined as:
$$ (b_i\^{'} \\times LB_i) \\leq b_i \\leq (b_i\^{'} \\times UB_i) \\space \\forall i $$

Where:

- \\(b_i\^{'}\\) is the non-optimized spend for channel $i$.
- \\(LB_i\\) is the user-specified lower bound with the value between \\(0\\) and \\(1\\).
- \\(UB_i\\) is the user-specified upper bound with the value greater than \\(1\\).