# Variable Transformations

There are two main variable transformations in the code:

- Adstock
- Diminishing returns

## #

AdstockThis technique is very useful for the better and more accurate representation of the real carryover effect of marketing campaigns. Moreover, it helps to improve the understanding of decay effects and how this can be used in campaign planning. It reflects the theory that the effects of advertising can lag and decay following initial exposure. In other words, not all effects of advertising are felt immediatelyâ€”memory builds and people sometimes delay actionâ€”and this awareness diminishes as time passes.

There are two adstock techniques you may choose from the code:

- Geometric: Traditionally the exponential decay function is used and on data controlled by theta the decay parameter. For example, an ad-stock of theta = 0.75 means that 75% of the impressions in Period 1 were brought to Period 2. Mathematically the traditional exponential adstock decay effect is defined as:

Below you will find the adstock geometric function within the code. Please bear in mind that all functions are located within the â€˜func.Râ€™ script.

- Weibull: Weibull survival function (Weibull distribution) provides much more flexibility in the shape and scale of the distribution. The formula is defined as:

This is the function within the code for weibull:

## #

Diminishing returnsThe theory of diminishing returns holds that each additional unit of advertising increases the response, but at a declining rate. This key marketing principle is reflected in marketing mix models as a variable transformation.

The nonlinear response to a media variable on the dependent variable can be modelled using a variety of functions. For example, we can use a simple logarithm transformation (taking the log of the units of advertising log(x) ), or a power transformation (x^alpha). In the case of a power transformation, the modeler tests the different variables (different levels of parameter x) for the highest significance of the variable in the model and the highest significance of the equation overall. However, the most common approach is to use the flexible S-curve transformation:

The variations of the parameters give modelers full flexibility on the look of the S-curve, specifically the shape and the inflection points:

This is the function within the code for Diminishing Returns (Hill function):