[R] Help with STL function in R compared to S-Plus

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Oct 22 14:37:45 CEST 2003


On Wed, 22 Oct 2003, Andrew White wrote:

> I am trying to understand the nuances of STL (seasonal trend 
> decomposition with loess) based on William Cleveland's (and others?) 
> original development. I do not understand the specification or use of 
> "frequency components" or equivalent "low-pass filter" components in 
> the stl() function.

Have you read the original paper? -- I found it helped.

> I have run the stl() function on a standard example data (co2) in both 
> S-Plus and in R version 1.8 and the stacked-panel plots are different. 
> The R version shows only rawdata, seasonal, (long-term) trend and then 
> remainder (residual).  The S-Plus version of the plot shows in addition 
> plots for the specified "frequency components". Why ?

Not the same function!

> In both versions of stl() the user specifies a univariate time series, 
> and the length of window for a seasonal component, a trend component 
> and one or more frequency (or low-pass filter) component(s).
> 
> Using the data "co2" as example, the S-Plus specification is something 
> like:
>    stl(co2, ss.window=17, fc.window=c(101,25), fc.degree=c(1,2)))
> 
> The near-equivalent specification of stl in R is something like:
>    stl(co2, s.window=17, l.window=c(101,25), l.degree=c(1,2))
> 
> The user has the option of selecting multiple frequency components in 
> S-Plus asa concatenation of values, as:  fc.window =c(101,25)  as the 
> S-Plus stl help page  example shows. It is NOT clear if such a 
> specification actually works in the R implementation of stl(), although 
> summary() of the stl output object shows that the values are entered 
> and stored in the routine.
> 
> Can anyone help explain the use and "tuning" of "frequency components" 
> in S-Plus version of STL and the parallel "low-pass filter" components 
> in R ? the RESULTS of specified frequency components show up in the 
> stl.plot in S-Plus as additional plot panels, whereas the low-pass 
> filter results do not! Only the raw-data, then seasonal, then trend, 
> and finally residuals plots are stacked up. This is what confuses me 
> the most: why the same routine from Wm. Cleveland and same named 
> function would show 2 different results and plot formats in S-Plus vs R.

It's not the same routine.  The R one is the one taken from the R 
reference, and I don't know what exactly is in S-PLUS but it is not the 
same code.

> Thanks very much for any help with this matter.
> Aloha from Hawaii, Andy White

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list