我在这里引用此文档: https ://mpra.ub.uni-muenchen.de/7683/4/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]}