stl {ts} | R Documentation |
Decompose a time series into seasonal, trend and irregular components.
stl(x, s.window = NULL, s.degree = 0, t.window = NULL, t.degree = 1, robust = FALSE, na.action = na.fail)
x |
A univariate time series to be decomposed.
This should be an object of class "ts" with a frequency
greater than one. |
s.window |
Either the string "periodic" or the span (in
lags) of the loess window for seasonal extraction, which should
be odd. This has no default. |
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 loess
procedure? |
na.action |
Action on missing values. |
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.
"stl"
with components
time.series |
a multiple time series with columns
seasonal , trend and remainder , |
weights |
the final robust weights (all one if fitting is not done robustly, |
call |
the matched call. |
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.
B.D. Ripley; Fortran code by Cleveland et al. (1990) from `netlib'.
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, 373.
loess
in package `modreg' (which is not
actually used in stl
).
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))