[R] Fast and simple tool for re-sampling of asynchronous time series ?

From: bruno Piguet <bruno.piguet_at_gmail.com>
Date: Fri, 25 Jun 2010 17:34:35 +0200

Hi all,

   I'm looking for a function which could do some fast and simple re-sampling of asynchronous time series.

   Below is a MCE of the kind of algorithm I need. As you can see, it's quite crude, but it's enough for my current needs. The only problem is that it is quite slow on real use case.

   I've got a C version which is much faster, but I'd like to have a pure-R program.

   Any pointer to the relevant part of the doc one one of the time-series packages ? Any suggestion or advice ?

   Thanks in advance,

B. Piguet.

Here is the exemple :
Tx <- seq(1, 50, 0.5)
Tx <- Tx + rnorm(length(Tx), 0, 0.1)
X <- sin(Tx/10.0) + sin(Tx/5.0) + rnorm(length(Tx), 0, 0.1) Ty <- seq(1, 50, 0.3333)
Ty <- Ty + rnorm(length(Ty), 0, 0.02)
Y <- sin(Ty/10.0) + sin(Ty/5.0) + rnorm(length(Ty), 0, 0.1)

w <- 0.25

Y_sync <- rep(NA, length(Tx))
for (i in 1:length(Tx))

   T_min <- Tx[i] - w
   T_max <- Tx[i] + w
   Y_sync[i] <- mean(Y[Ty >= T_min & Ty <= T_max ])

diff = X - Y_sync

plot (diff~Tx, type="l")

        [[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 25 Jun 2010 - 15:36:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jun 2010 - 17:00:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive