2

我在这里引用此文档: https ://mpra.ub.uni-muenchen.de/7683/4/Adstock

在第 6 页有一个 AdStock 转换公式,如下所示: 在此处输入图像描述

我在下面找到了一个重现此 adstock 转换的 R 代码: https ://analyticsartist.wordpress.com/2013/11/02/calculating-adstock-effect/

在此处输入图像描述

R-代码:

adstock_rate = 0.50
advertising = c(117.913, 120.112, 125.828, 115.354, 177.090, 141.647, 137.892,   0.000,   0.000,   0.000,   0.000, 
            0.000,   0.000,   0.000,   0.000,   0.000,   0.000, 158.511, 109.385,  91.084,  79.253, 102.706, 
            78.494, 135.114, 114.549,  87.337, 107.829, 125.020,  82.956,  60.813,  83.149,   0.000,   0.000, 
            0.000,   0.000,   0.000,   0.000, 129.515, 105.486, 111.494, 107.099,   0.000,   0.000,   0.000, 
            0.000,   0.000,   0.000,   0.000,   0.000,   0.000,   0.000,   0.000)

adstocked_advertising = numeric(length(advertising))
adstocked_advertising[1] = advertising[1]
for(i in 2:length(advertising)){
  adstocked_advertising[i] = advertising[i] + adstock_rate * 
adstocked_advertising[i-1]
}

阴谋:

在此处输入图像描述

When I attempted to use the formula on page 6, my output looked way different and did not seem accurate. Does anyone know how to reproduce the first formula rather than the last?

Here was my attempt:

adstocked_advertising = numeric(length(advertising))
adstocked_advertising[1] = advertising[1]
for(i in 2:length(advertising)){
 adstocked_advertising[i] = 1/(1+exp(-v*advertising[i])) + 
adstock_rate*adstocked_advertising[i-1]}

Output plot: 在此处输入图像描述

4

0 回答 0