[R] Irregular time series
Philippe Grosjean
phgrosjean at sciviews.org
Tue Jan 28 09:45:03 CET 2003
You will find all required tools in the PASTECS library, including
regul.screen() and regul.adj() to determine best time step in the regular
series (with a maximum number of observations matching those in the initial
irregular series), and four different regulation methods: regconst(),
reglin(), regspline() and regarea(), all available in the more general
regul() function.
Best,
Philippe Grosjean
...........]<(({?<...............<?}))><...............................
) ) ) ) )
( ( ( ( ( Dr. Philippe Grosjean
) ) ) ) )
( ( ( ( ( LOV, UMR 7093
) ) ) ) ) Station Zoologique
( ( ( ( ( Observatoire Oceanologique
) ) ) ) ) BP 28
( ( ( ( ( 06234 Villefranche sur mer cedex
) ) ) ) ) France
( ( ( ( (
) ) ) ) ) tel: +33.4.93.76.38.16, fax: +33.4.93.76.38.34
( ( ( ( (
) ) ) ) ) e-mail: phgrosjean at sciviews.org
( ( ( ( ( SciViews project coordinator (http://www.sciviews.org)
) ) ) ) )
.......................................................................
-----Original Message-----
From: r-help-admin at stat.math.ethz.ch
[mailto:r-help-admin at stat.math.ethz.ch]On Behalf Of Damon Wischik
Sent: lundi 27 janvier 2003 10:42
To: r-help at stat.math.ethz.ch
Subject: [R] Irregular time series
I have an irregular time series, stored as a data frame, in the form
Time Bytes
57213.191 20
57213.193 20
57213.300 23
... ...
How should I convert this into a regularly-spaced time series?
I have in mind to divide time into equal-sized intervals, and sum the
number of Bytes in each interval. I tried this:
its.to.ts <- function(times,values,delta=1) {
m <- min(times)
M <- max(times)
mm <- delta*floor(m/delta)
MM <- delta*ceiling(M/delta)
cuts <- seq(from=mm,to=MM,by=delta)
nullvals <- rep(0,length(cuts)-1)
nulltimes <- cuts[-1]-delta/2
time.factor <- cut(c(times,nulltimes),cuts,labels=FALSE)
dd <- aggregate(c(values,nullvals),by=list(time=time.factor),sum)
ts(data=dd$x,start=mm,deltat=delta)
}
but it is very slow (for a data frame of 102,000 lines, converted into a
time series of 130,000 points). Is there a better way?
Damon Wischik.
______________________________________________
R-help at stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list