Skip to content

differencing a time series

2 messages · oliver wee, Brian Ripley

#
Hello, I need some help in differencing a time series.

For example I have a data set with 100 data points. I
need to create a new dataset that consists of the
difference of two succeeding data points.

something akin to this formula in java:
for (int i = 0, i < 100, i++)
{
  newdataset[i] = olddataset[i] - olddataset[i-1]
}

any help is appreciated. Thanks
#
On Sun, 12 Feb 2006, oliver wee wrote:

            
Surely that is incorrect: what is olddataset[-1] in Java?

R does this right in diff().