differencing a time series

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

differencing a time series

oliver wee
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: differencing a time series

Brian Ripley
On Sun, 12 Feb 2006, oliver wee wrote:

> 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]
> }

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

R does this right in diff().

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html