[R] how to smooth timeseries without the lagging?

Gabor Grothendieck ggrothendieck at gmail.com
Sat Jul 25 12:13:06 CEST 2009


On Sat, Jul 25, 2009 at 5:07 AM, Dieter
Menne<dieter.menne at menne-biomed.de> wrote:
>
>
>
> losemind wrote:
>>
>> If I use a moving average, it will smooth the choppy time series, but
>> it will lead to lagging...
>>
>
> The lagging can only be removed if you look into the future, otherwise you
> run into causality problems.
> So the easiest way is to center your output data on half the window width.
> Not using a rectangular weighting is recommended.
>

Note that rollmean/rollmax/rollmedian/rollapply in the zoo package centers
by default and whether its centered or left and or right aligned is controlled
by the align= argument.




More information about the R-help mailing list