Skip to content
Prev 325658 / 398503 Next

how to get growth rate of a (time series) data?

On 19/06/13 23:24, R. Michael Weylandt wrote:
<SNIP>

No, "clearly" ( :-) ) it doesn't.  It gives

(Y[2] - Y[1])/Y[2], (Y[3]-Y[2])/Y[3], .... when what is wanted is

(Y[2] - Y[1])/Y[1], (Y[3]-Y[2])/Y[2], ....

The OP needs to do:

     with(test,diff(Y)/Y[-length(Y)])

This is yet another illustration of the rule that if there is a 50-50 
chance of
getting things the wrong way around, then there is actually a probability
of one of getting things the wrong way around.

     cheers,

         Rolf