[R] Irregular time series

Damon Wischik djw1005 at cam.ac.uk
Tue Jan 28 11:25:05 CET 2003

>> 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: ... 

Philippe Grosjean wrote:
> 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.

Thank you for the link. As I understand them, none of those regulation
methods achieve what I want. I want to divide time into equal-sized
intervals, and sum the number of bytes arriving in each interval. I do not
want any sort of interpolation of existing values. Those four regulation
methods are all different types of interpolation, if I understand

My dataset represents a point arrival process, not a sample of a
continuous process; I want to turn the continuous-time point arrival
process into a discrete-time point arrival process. I am looking for a
function which has the same effect as, but is faster than, 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)
>   }

Damon Wischik.

More information about the R-help mailing list