Salim Alexander (salimale)
2010-Nov-01 15:14 UTC
[R] Post-processing of approximated irregular time series
Hi all, Issue: I merged two zoo objects (a regular and an irregular). After the merge I used the function 'na.approx' to have also values in the resolution of the regular time series. Problem: After approximation some rows at the beginning or at the end of the zoo objects disappear due to the 'na.approx' algorithm. Now I just want to have all the rows of the regular time series with the approximated values of the irregular time series back. Because some rows disappear I wasn't able to program a code which works properly for 'all' circumstances. I also tried to work with the 'index' function. Didn't work out so far. Thank you for your help. Regards, Alex [[alternative HTML version deleted]]
Gabor Grothendieck
2010-Nov-01 16:04 UTC
[R] Post-processing of approximated irregular time series
On Mon, Nov 1, 2010 at 11:14 AM, Salim Alexander (salimale) <salimale at students.zhaw.ch> wrote:> Hi all, > > Issue: I merged two zoo objects (a regular and an irregular). After the merge I used the function 'na.approx' to have also values in the resolution of the regular time series. > > Problem: After approximation some rows at the beginning or at the end of the zoo objects disappear due to the 'na.approx' algorithm. Now I just want to have all the rows of the regular time series with the approximated values of the irregular time series back. Because some rows disappear I wasn't able to program a code which works properly for 'all' circumstances. I also tried to work with the 'index' function. Didn't work out so far. > > Thank you for your help. > > Regards, > AlexNote the last line to every message to r-help asking for minimal reproducible code. Without that one cannot be sure what the problem is but note the na.rm= argument on na.approx.zoo . -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Alexander Salim
2010-Nov-01 17:05 UTC
[R] Post-processing of approximated irregular time series
Hi all, Issue: I merged two zoo objects (a regular and an irregular). After the merge I used the function 'na.approx' to have also values in the resolution of the regular time series. Problem: After approximation some rows at the beginning or at the end of the zoo objects disappear due to the 'na.approx' algorithm. Now I just want to have all the rows of the regular time series with the approximated values of the irregular time series back. Because some rows disappear I wasn't able to program a code which works properly for 'all' circumstances. I also tried to work with the 'index' function. Didn't work out so far. Thank you for your help. Regards, Alex *********************************************************** funLm <- function(gauge, orange){ gauge <- zoo(gauge$Precipitation, order.by = gauge$Time) tstart <- ISOdatetime(year=2009, month=5, day=1, hour = 0, min = 0, sec = 0, tz = "UTC") tend <- ISOdatetime(year=2009, month=5, day=31, hour = 23, min = 59, sec 59, tz = "UTC") orangeMai <- window(orange, start=tstart, end=tend) gaugeMai <- window(gauge, start=tstart, end=tend) mergeGaugeOrange <- merge.zoo(gaugeMai, orangeMai) smoothing <- na.approx(mergeGaugeOrange) na.index <- which(is.na(mergeGaugeOrange$orangeMai)) na.index <- if(na.index[1] != 1){na.index-(na.index[1]-1)} regularZoo <- smoothing[c(na.index)] rain.lm <- lm(orangeMai ~ gaugeMai, data=regularZoo) par(mfrow=c(2,2)) plot(rain.lm) } *********************************************************** [[alternative HTML version deleted]]