Seasonal Decomposition of a Time Series

DESCRIPTION:
Decompose a time series into frequency components of variation by a sequence of loess smoothings.

USAGE:
stl(time.series, ss.window = NULL, ss.degree = 0, ss.robust = F,
     s.window = NULL, s.degree = 2, fc.window = NULL, fc.degree = 2,
     control, ...)

REQUIRED ARGUMENTS:
time.series:
a univariate time series that is to be decomposed.

OPTIONAL ARGUMENTS:
ss.window:
a single value that is character or numeric. If it is the character value "periodic", an exactly periodic seasonal component is returned. If the argument is numeric, it specifies the length of the window in the loess smoothing for each seasonal subseries in phase one of the decomposition. This must be an odd integer. A seasonal subseries consists of the values of the seasonal component at a given position in the seasonal cycle (e.g., January values of a monthly series with a yearly cycle); the number of subseries is frequency(time.series). As ss.window increases, each subseries becomes smoother. If missing, no seasonal component is computed.
ss.degree:
degree of locally-fitted polynomial in the loess smoothing for the seasonal subseries in phase one of the decomposition. Values of 0 (locally-constant fitting) and 1 (locally-linear fitting) are allowed. Using the first results in increased stability of the seasonal component. The default is 0.
ss.robust:
a logical. If TRUE, a robust fitting procedure is used in phase one.
s.window:
length of the window of the phase-two loess smoothing of the seasonal component from phase one.
s.degree:
degree of locally-fitted polynomial in the loess smoothing of the seasonal in phase two. Values of 1 (locally-linear fitting) and 2 (locally-quadratic fitting) are allowed. Normally, the value should be 2, the default.
fc.window:
vector of lengths of windows in loess smoothings for other frequency components in phase two of the decomposition. If a seasonal component is present, it is subtracted from time.series; if not, the procedure begins with time.series. A frequency component is computed by a loess fit with the window length equal to the first element of fc.window, the component is removed, another component is computed with the window length equal to the second element of fc.window, and so forth. In most cases, the values of the argument should be decreasing, that is, the frequency bands of the fitted components should increase. If the argument ss.robust is TRUE, the robustness weights from the phase one seasonal fit are used as weights in the loess fitting.
fc.degree:
vector of degrees of locally-fitted polynomial in the loess smoothings for the frequency components specified in fc.window. Values of 1 and 2 are allowed. If the length of fc.degree is less than that of fc.window, the former is expanded to the length of the latter using rep; thus, giving the value 1 specifies a degree of 1 for all components.
control:
a list that controls certain parameters in both phase-one and phase-two fitting. The list can be created by the function stl.control, whose documentation describes the options. Most users do not need to alter the default values for these parameters.
...:
arguments of the function stl.control can also be specified directly in the call to stl without using the argument control. See help file for stl.control for details.

VALUE:
an object of class "stl" representing the fitted model.

DETAILS:
There are methods for these objects including print.stl, plot.stl, and specs.stl. The object is a list whose components include the computed frequency components as time series with the same attributes as time.series. The names of these components are included in the printing of print.stl, and the components together with the series are graphed by plot.stl.

specs.stl can be used to recall the specifications used to compute an object of class stl. Some of these values may be slightly different from the input values given the algorithm requirements.

stl carries out a decomposition of a time series into frequency components of variation by a sequence of loess smoothings. In phase one, the backfitting algorithm produces a seasonal component with a period equal to that of frequency(time.series). The subseries of this component are smooth though time; that is, for a monthly series with period 12, the January values are smooth, the February values are smooth and so forth. But the values by design do not have to be smooth from one month to the next. If this is desired, the phase-one seasonal is replaced by a smoothing of it in the first step of phase two. The seasonal is subtracted from time.series and other frequency components are computed sequentially. stl is a replacement for the sabl procedure.


REFERENCES:
Cleveland, R. B., Cleveland, W. S., McRae, J. E. and Terpening, I. (1990). STL: A Seasonal-Trend Decomposition Procedure Based on Loess. Journal of Official Statistics, 6, 3-73.

SEE ALSO:
plot.stl , specs.stl , stl.control .

EXAMPLES:
stl(co2, ss.window = 17, fc.window = c(101, 25), fc.degree = c(1, 2))

# produces the following output: Call: stl(time.series = co2, ss.window = 17, fc.window = c(101, 25), fc.degree = c(1, 2)) Frequency components of stl object: fc.101 fc.25 seasonal remainder