stl {ts} | R Documentation |
Seasonal Decomposition of Time Series by Loess
Description
Decompose a time series into seasonal, trend and irregular components.
Usage
stl(x, s.window = NULL, s.degree = 0, t.window = NULL, t.degree = 1,
robust = FALSE, na.action = na.fail)
Arguments
x |
A univariate time series to be decomposed.
This should be an object of class |
s.window |
Either the string |
s.degree |
Degree of locally-fitted polynomial in seasonal extraction. Should be zero or one. |
t.window |
The span (in lags) of the loess window for trend extraction, which should be odd. There is a reasonable default. |
t.degree |
Degree of locally-fitted polynomial in trend extraction. Should be zero or one. |
robust |
Should robust fitting be used in the |
na.action |
Action on missing values. |
Details
The seasonal component is found by loess smoothing the
seasonal sub-series (the series of all January values, ...); if
s.window = "periodic"
smoothing is effectively replaced by
taking the mean. The seasonal values are removed, and the remainder
smoothed to find the trend. The overall level is removed from the
seasonal component and added to the trend component. This process is
iterated a few times. The remainder
component is the
residuals from the seasonal plus trend fit.
Value
An object of class "stl"
with components
time.series |
a multiple time series with columns
|
weights |
the final robust weights (all one if fitting is not done robustly, |
call |
the matched call. |
Note
This is similar to but not identical to the stl
function in
S-PLUS. The remainder
component given by S-PLUS is the sum of
the trend
and remainder
series from this function.
Author(s)
B.D. Ripley; Fortran code by Cleveland et al. (1990) from ‘netlib’.
References
R. B. Cleveland, W. S. Cleveland, J.E. McRae, and I. Terpenning (1990). STL: A Seasonal-Trend Decomposition Procedure Based on Loess. Journal of Official Statistics, 6, 3–73.
See Also
loess
in package ‘modreg’ (which is not
actually used in stl
).
Examples
data(nottem)
plot(stl(nottem, "per"))
data(co2)
plot(stl(log(co2), s.window=21))
## linear trend, strict period.
plot(stl(log(co2), s.window="per", t.window=1000))