[R] Moving Average

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Feb 26 15:54:46 CET 2009


On 26-Feb-09 13:54:51, David Winsemius wrote:
> I saw Gabor's reply but have a clarification to request. You say you  
> want to remove low frequency components but then you request smoothing 
> functions. The term "smoothing" implies removal of high-frequency  
> components of a series.

If you produce a smoothed series, your result of course contains
the low-frequency comsponents, with the high-frequency components
removed.

But if you then subtract that from the original series, your result
contains the high-frequency components, with the low-frequency
compinents removed.

Moving-average is one way of smoothing (but can introduce periodic
components which were not there to start with).

Filtering a time-series is a very open-ended activity! In many
cases a useful start is exploration of the spectral properties
of the series, for which R has several functions. 'spectrum()'
in the stats package (loaded bvy default) is one basic function.
help.search("time series") will throw up a lot of functions.

You might want to look at package 'ltsa' (linear time series
analysis).

Alternatively, if yuou already have good information about the
frequency-structure of the series, or (for instance) know that
it has a will-defined seasonal component, then you could embark
on designing a transfer function specifically tuned to the job.
Have a look at RSiteSearch("{transfer function}")

Hoping this helps,
Ted.



> If smoothing really is your goal then additional R resource would be  
> smooth.spline, loess (or lowess), ksmooth, or using smoothing terms in 
> regressions. Venables and Ripley have quite a few worked examples of  
> such in MASS.
> 
> -- 
> David Winsemius
> 
> 
> On Feb 26, 2009, at 7:07 AM, <mauede at alice.it> wrote:
> 
>> I am looking for some help at removing low-frequency components from  
>> a signal, through Moving Average on a sliding window.
>> I understand thiis is a smoothing procedure that I never done in my  
>> life before .. sigh.
>>
>> I searched R archives and found "rollmean", "MovingAverages {TTR}",  
>> "SymmetricMA".
>> None of the above mantioned functions seems to accept the smoothing  
>> polynomial order and the sliding window with as input parameters.  
>> Maybe I am missing something.
>>
>> I wonder whether there is some building blocks in R if not even a  
>> function which does it all (I do not expect that much,though).
>> Even some literature references and/or tutorials are very welcome.
>>
>> Thank you so much,
>> Maura
>>
>>
>>
>> tutti i telefonini TIM!
>>
>>
>>      [[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.
> 
> ______________________________________________
> 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.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 26-Feb-09                                       Time: 14:54:43
------------------------------ XFMail ------------------------------




More information about the R-help mailing list