我在这里引用这个文件: https://mpra.ub.uni-muenchen.de/7683/4/Adstock
在第6页上有一个AdStock Transformation的公式如下:
我找到了一个R代码,可以在下面重现这个adstock转换: https://analyticsartist.wordpress.com/2013/11/02/calculating-adstock-effect/
R-Code:
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]
}
情节:
当我尝试使用第6页的公式时,我的输出看起来有所不同,看起来并不准确。有谁知道如何重现第一个公式而不是最后一个?
这是我的尝试:
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]}