Nonlinear Smoothing Using Running Medians

DESCRIPTION:

Robustly smooths a time series by means of running medians.

USAGE:

smooth(x, twiceit=T) 

REQUIRED ARGUMENTS:

x
numeric vector, matrix, univariate or multivariate time series to be smoothed. Time series may be regular or calendar (class "rts" or "cts") but not irregular (class "its"). The length of each vector, column, or channel must be at least four. Missing values ( NA, NaN or Inf) are not accepted.

OPTIONAL ARGUMENTS:

twiceit
logical flag. If TRUE, smooth performs twicing. Twicing is the process of smoothing, computing the residuals from the smooth, smoothing these, and then adding the two smoothed series together. By default, twiceit=TRUE.

VALUE:

a smoothed regular time series computed by using a method of running medians known as 4(3RSR)2H. See the DETAILS section below for a description of this method.

DETAILS:

The object to be smoothed is coerced to a regular time series. The components of the smoothing process are as follows:

4

Running medians of length 4.

3RSR
Medians of 3, repeated until convergence, split, and repeated until convergence.
2
Running medians of length 2.
H
Hanning, a centered weighted running average with weights 1/4, 1/2, 1/4.

REFERENCES:

Tukey, J.W. (1977). Exploratory Data Analysis. Reading, Massachusetts: Addison-Wesley.

Velleman, P.F. and Hoaglin, D.C. (1981). Applications, Basics, and Computing of Exploratory Data Analysis. Boston: Duxbury.

McNeil, D.R. (1976). Interactive Data Analysis.

SEE ALSO:

, , .

EXAMPLES:

tsplot(hstart, lty=2) 
lines(smooth(hstart))