time series - R code for calculating ad stock / decay with carry over effect limit -


given vector x say,

x <- c(10,0,0,20,0,0) 

and ad stock of 0.8, how calculate ad stock effect such if carry on effect less limit k, half of original value, no longer carried over.

without condition, can use this:

filter(x, filter=0.8, method="recursive") 

which gives

10.0000  8.0000  6.4000 25.1200 20.0960 16.0768 

but given condition, if apply adstock of 0.2 10 gives,

10.0000  8.0000  6.4000  5.1200  4.096  3.2768  ... 

the carry on effect should stop @ 5.12 since 4.096 less half of 10. expected output be:

10.0000  8.0000  6.4000 25.1200 16.0000 12.8000 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -