Seasonal Decomposition

DESCRIPTION:
Decomposes a univariate time series into a trend, a seasonal component, an optional calendar component and noise.

USAGE:
sabl(x, power=<<see below>>, calendar=F, trend=11,
     seasonal=15, revisions=F)

REQUIRED ARGUMENTS:
x:
a univariate time series with frequency greater than 1. There must be at least 3 complete cycles, and missing values (NAs) are not allowed.

OPTIONAL ARGUMENTS:
power:
vector of powers for transforming x: sabl will pick the value from power that minimizes a measure of the interaction between trend and seasonal components. For a value p in power, p>0 corresponds to the transformation x^p; p==0 to log(x); and p<0 to -x^p. If x has any zero or negative values, no transformation is made (power is forced to just 1). Otherwise, the default is c(-1, -.5, -.25, 0, .25, .5, 1).
calendar:
if FALSE, no calendar component is computed. Calendar computation can be done only for monthly data.
trend:
an odd integer greater than 2 giving the number of points in the trend smoothing window.
seasonal:
an odd integer greater than 2 giving the number of points in the seasonal smoothing window.
revisions:
if FALSE, no revisions are calculated. The series must be at least 7 cycles long for revisions to be calculated. A maximum of 5 cycles of revisions is calculated.

VALUE:
list with the following components:
trend:
time series giving the long term change in level.
seasonal:
time series giving the part of x that repeats or nearly repeats every frequency(x) time units. This series contains predicted seasonal values for one additional cycle.
irregular:
time series giving the noisy variation not explained by trend or seasonal (or calendar if computed).
transformed:
the series x after power transformation and month length correction, from which the components are extracted. Month length correction is only performed when calendar=TRUE.
adjusted:
time series with the seasonal component and calendar component (if computed) removed, on the original (untransformed) scale.
calendar:
time series of variation due to day-of-the-week effect. This is returned only if the calendar argument is TRUE. This series contains predicted calendar values for one additional cycle.
power:
the power that was actually used in transforming the time series x.
tstat:
vector of t statistics used to pick the power with which to transform x. This is only returned if the length of the input power is greater than 1.
revisions:
time series of revisions, if computed.
weights:
time series of final robustness weights used in the decomposition.

DETAILS:
sabl performs five tasks, some of which are optional. These tasks are: choose a transformation (optional), compute a calendar component (optional), decompose the series, compute the adjusted series, and compute revisions (optional). We discuss each of these in turn.

TRANSFORM. A power transformation is chosen that minimizes a t-test of the interaction between the trend component and the seasonal component from among the powers that are in the input power. No transformation is performed if there are non-positive values in the series. A decomposition in which the amplitude of seasonal component is related to the trend may need a different transformation.

CALENDAR. The calendar component is only useful when the data are monthly, aggregated (e.g., the sum of sales for each month), and there is likely to be a day of the week effect. A month length correction is made: each element of the series is multiplied by 30.4375 divided by the number of days in the month for the particular element. (30.4375 = 365.25/12 is the average number of days per month.) A regression is then performed with a parameter for each day of the week to estimate the calendar component.

DECOMPOSE. The components returned by sabl are related as follows:

transformed equals trend + seasonal + irregular (if no calendar component was computed)

or

transformed equals trend + seasonal + calendar + irregular (if a calendar component was computed)

The estimation procedure first uses a running median smooth, which produces robustness weights from the size of the estimated irregular. These robustness weights multiplied with bisquare weights are used with a weighted running mean smooth. New robustness weights are computed and another weighted running mean smooth is performed. Weighted linear regression is used to estimate at the ends of the series where a running mean is ill- defined. The seasonal and calendar component include an additional cycle so that adjustments can be made to new data from previous estimation.

ADJUST. The adjusted component is the inverse transformation of the transformed series minus the seasonal component (and the calendar component, if present).

REVISIONS. Revisions are a measure of the variability of the adjustments. There are two ways to make adjustments, which we will term "actual adjustments" and "prediction adjustments". Actual adjustments require that the decomposition be performed with data that includes the cycle in question; prediction adjustments use the seasonal component (and calendar component) from the decomposition with data ending just prior to the cycle in question. If we let A be the time series of actual adjustments for the time points at which revisions are calculated and P is the time series of prediction adjustments at the same time points, then the revision is (A/P - 1) * 100 ( = ((A - P)/P) * 100) if the minimum of all of the adjustments is greater than zero. Otherwise, the revision is P - A. That is, if all adjusted values are positive, then a percent relative difference is computed, otherwise just a difference is computed.


NOTE:
The routine stl is the preferred way to compute seasonal decompositions-sabl is obsolete and will likely be removed from future distributions.

REFERENCES:
Cleveland, W. S. and Devlin, S. J. (1982). Calendar effects in monthly time series: modeling and adjustment. Journal of the American Statistical Association 77, 520-528.

Cleveland, W. S., Devlin, S. J. and Terpenning, I. J. (1981). The SABL statistical and graphical methods. Computing Information Library, Bell Labs, 600 Mountain Ave., Murray Hill, N.J. 07974, USA

Cleveland, W. S., Devlin, S. J. and Terpenning, I. J. (1981). The details of the SABL transformation, decomposition and calendar methods. Computing Information Library, Bell Labs, 600 Mountain Ave., Murray Hill, N.J. 07974, USA


SEE ALSO:
sablplot , monthplot .

EXAMPLES:
  h <-
sabl(hstart)     #decomposition   of   housing   starts    series
tsplot(hstart,   h$adjusted,   lty=2:1,   col=1)   legend(1966.7,
210,c("unadjusted",  "adjusted"),  lty=2:1)   title(main="Housing
Starts")