Skip to contents

A function to apply the geometric adstock transfromation to a vector of media impressions

Usage

geometric_adstock(x, decay = 0.5, max_carryover = 12, normalize = TRUE)

Arguments

x

input vector

decay

decay rate

max_carryover

maximum carryover

normalize

should the result be scaled?

Value

a numeric vector of length(x) with adstock transformed media impressions.

Examples

data(mmm_imps)
x <- mmm_imps$mi_banners
a <- geometric_adstock(x)
b <- geometric_adstock(x, decay = 0.7, max_carryover = 2)

x[1:12]
#>  [1]    0.000 3731.596 2217.981    0.000 4274.270 2801.566 3329.304 2652.199
#>  [9] 3066.319 2415.696    0.000    0.000
a[1:12]
#>  [1]    0.0000 1866.2536 2042.3879 1021.1939 2648.2540 2725.2522 3027.6844
#>  [8] 2840.2657 2953.6667 2684.9764 1342.4882  671.2441
b[1:12]
#>  [1]    0.0000 2195.0564 2841.2339  913.2861 2514.2767 3407.9738 3112.0000
#>  [8] 2931.0070 2895.7990 2683.5997  994.6985    0.0000

plot(x[1:20], type = "l", main = "Geometric Adstock Transformation of x")
lines(a[1:20], col = 2)
lines(b[1:20], col = 3)