[R-SIG-Finance] interpolating missing values from a TS

Matthieu Stigler matthieu.stigler at gmail.com
Wed Oct 7 11:38:54 CEST 2009


Have a look on
http://www.rmetrics.org/ebooks/TimeSeriesFAQ.pdf

p 101, which discusses interpolation ( na.approx, na.splines) for
different time series classes.

Matthieu

2009/10/7 Aleks Clark <aleks.clark at gmail.com>:
> I've got a large TS with occasional NAs I'd like to roughly
> interpolate, I'm currently doing this but it's pretty slow:
>
>        lapply(1:nrow(delta), function(i) {
>                lapply(1:ncol(delta), function(j) {
>                        if (is.na(delta[i,j])) {
>                                if ((i==1)||is.na(delta[i-1,j])) {
>                                  delta[i,j] <- delta[i+1,j]
>                                } else { delta[i,j] <- delta[i-1,j]}
>                        }
>                })
>        })
>
> any ideas for a better solution?
>
>
> --
> Aleks Clark
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list