[R] merging, interpolating two simulataneous time series
Steve Powers
smpowers at wisc.edu
Mon Oct 1 10:03:54 CEST 2007
I have a time series for two variables measured simultaneously, but at
different intervals. The variables are not independent, so the patterns
in the times series are very similar (one variable goes up when the
other goes up, etc).
For example, let's pretend my data look something like this (but with
more noise)...
var1_times<-c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
var1_values<-c(0, 0.5, 1.0, 1.5, 2.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0)
var2_times<-c(0, 2, 5.0, 7, 10.0)
var2_values<-c(50, 55, 60, 55, 50)
Note that var2 is always sampled at a time when a corresponding var1
measurement was taken, but some var1 measurements were taken alone. I'm
trying to increase the frequency of the var2 time series in a model by
taking into account the parallel information in the var1 time series.
Essentially, this means I want to do a local regression of
var2_values~var1_values by fitting a different relationship for each
time interval. I've used approx and approxfun in the past and found them
helpful, but can't figure out how to employ them in this case. Any
thoughts on how to do this? In the end, I want interpolated values for
var2 that line up with the var1 times.---steve
I'm using R version 2.4 in Windows XP.
More information about the R-help
mailing list