Hi I am currently struggling to get a cumulative 'decayed' sum of variables. For example, if variable y has value like: day y 1 4 2 3 3 2 4 6 5 1 6 2 i want to get a variable 'desumy', by each person (let's assume that example that i brought is from a single person), assuming that decaying rate is 0.5 in a day: day y desumy 1 4 0 2 3 4*0.5 3 2 4*0.5*0.5 + 3*0.5 4 6 4*0.5*0.5*0.5 + 3*0.5*0.5 5 1 4*0.5*0.5*0.5 + 3*0.5*0.5 6 2 i figured out that all i have to do is to create variable 'desumy' that satisfies desumy_t = (desumy_t-1 + y_t-1)*0.5, but i am struggling to make a code implementing what i want. Thank you.
... View more