# Input data

Define the following index variables:

• $$g=1,\ldots,G$$ indexes the geographical units.
• $$t=1,\ldots,T$$ indexes the time units.

For media variables, data for time periods $$t<1$$ can be included in the model input data to accurately model lagged effects in the earlier time periods. If data for $$t<1$$ is not provided, it is assumed that there is no media execution prior to $$t=1$$.

• $$c=1,\ldots,C$$ indexes the control variables.

• $$m=1,\ldots,M$$ indexes the media channels without reach and frequency data.

• $$n=1,\ldots,N$$ indexes the media channels with reach and frequency data.

Meridian requires three main data arrays as model inputs (KPI, controls, and media). For channels with reach and frequency data available by geo and time period, the reach and frequency data can optionally be used instead of a single media metric. A unit value is required for KPI and media data so that units can be converted to a currency value for ROI calculations.

Data Dimensions Model Input: Raw Units Model Input: Unit Value Transformed Units (used in model equation) Value/Cost
KPI $$G \times T$$ $$\overset{\cdot \cdot}{y}_{g,t}$$ $$u^{(y)}_{g,t}$$ $$y_{g,t} = L^{(y)}_g (\overset{\cdot \cdot}{y}_{g,t})$$ $$\overset{\sim}y_{g,t} = u^{(y)}_{g,t} \cdot \overset{\cdot \cdot}{y}_{g,t}$$
Controls $$G \times T \times C$$ $$\overset{\cdot \cdot}{z}_{g,t,c}$$ $$\text{N/A}$$ $$z_{g,t,c} = L^{(x)}_{g,c}(\overset{\cdot \cdot}{z}_{g,t,c})$$ $$\text{N/A}$$
Media $$G \times T \times M$$ $$\overset{\cdot \cdot}{x}_{g,t,m}$$ $$u^{(x)}_{g,t,m}$$ $$x_{g,t,m} = L^{(x)}_{g,m}(\overset{\cdot \cdot}{x}_{g,t,m})$$ $$\overset{\sim}x_{g,t,m} = u^{(x)}_{g,t,m}\cdot\overset{\cdot \cdot}{x}_{g,t,m}$$
Reach $$G \times T \times N$$ $$\overset{\cdot \cdot}{r}_{g,t,n}$$ $$u^{(rf)}_{g,t,n}$$ $$r_{g,t,n} = L^{(rf)}_{g,n}(\overset{\cdot \cdot}{r}_{g,t,n})$$ $$\overset{\sim}r_{g,t,n} = u^{(rf)}_{g,t,n} \cdot \overset{\cdot \cdot}{r}_{g,t,n} \cdot f_{g,t,n}$$
Frequency $$G \times T \times N$$ $$\overset{\cdot \cdot}{f}_{g,t,n}$$ $$u^{(rf)}_{g,t,n}$$ $$\text{N/A}$$ $$\overset{\sim}r_{g,t,n} = u^{(rf)}_{g,t,n} \cdot \overset{\cdot \cdot}{r}_{g,t,n} \cdot f_{g,t,n}$$

Unit transformations are handled internally by Meridian. Geo population scaling is necessary for hierarchical modeling to put all geos on a comparable scale. Other standardization is done so that standardized prior distributions can be used, without the need to consider the scale of each variable.

Define $$p_g$$ to be the population size of each geo, which is another model input that must be specified by the user. The linear transformations are summarized as follows:

## Transformation: KPI units

Notation: $$L^{(y)}_g (\cdot)$$

Description:

1. Divide by geo population.
2. Center and scale the geo-scaled values to have mean zero and standard deviation one.

Definition:

$$L^{(y)}_g (q) = \dfrac{\dfrac{q}{p_g} - m}{s}$$

Where:

• $$y^\dagger_{g,t} = \dfrac{\overset {\cdot \cdot} y_{g,t}}{p_g}$$
• $$m = \frac{1}{GT}\sum\limits_t y^\dagger_{g,t}$$
• $$s = \sqrt{\frac{1}{GT-1} \sum\limits_{g,t} \left( y^\dagger_{g,t}-m \right)^2}$$

## Transformation: Control variables

Notation: $$L^{(z)}_{g,c} (\cdot)$$

Description:

1. It might make sense to do population scaling for certain controls. This can be handled using the control_population_scaling_id argument. By default, no controls are population scaled.

2. Center and scale each control variable to have mean zero and standard deviation one.

Definition:

$$L^{(z)}_{g,c}(q) = \dfrac{\dfrac{q}{p^{l_c}_g} - m_c}{s_c}$$

Where:

• $$I_c = 1$$ if control_population_scaling_id=True is used for the variable $$c;0$$ otherwise.

• $$z_{g,t,c}^ \dagger = \dfrac{\overset {\cdot \cdot} x_{g,t,c}}{p_g^{I_c}}$$
• $$m_c = \frac{1}{GT}\sum\limits_{g,t} z^\dagger_{g,t,c}$$
• $$s_c = \sqrt{\frac{1}{GT-1} \sum\limits_{g,t} \left( z^\dagger_{g,t,c}-m_c \right)^2}$$

## Transformation: Media units

Notation: $$L^{(x)}_{g,m} (\cdot)$$

Description:

1. Divide by geo population.
2. For each media channel, scale the geo-scaled values by the median non-zero value.

Definition:

$$L^{(x)}_{g,m} (q) = \dfrac{q}{p_g d_m}$$

Where:

• $$x_{g,t,m}^ \dagger = \dfrac{\overset {\cdot \cdot} x_{g,t,m}}{p_g}$$
• $$d_m = \text{Median}\left( \left\{ x^\dagger_{g,t,m}:x^\dagger_{g,t,m} > 0 \right\}_{g,t} \right)$$

## Transformation: Reach

Notation: $$L^{(rf)}_{g,n} (\cdot)$$

Description:

The transformation function is the same as for media units.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]
{"lastModified": "Last updated 2024-06-21 UTC."}