smooth
Nonlinear Smoothing Using Running Medians

### Description

Robustly smooths a time series by means of running medians.

### Usage

    smooth(x, kind = c("3RS3R", "3RSS", "3RSR", "3R", "3", "S"),
        twiceit = FALSE, endrule = "Tukey", do.ends = FALSE)

### Arguments

x | a numeric vector, matrix, univariate or multivariate time series to be smoothed. Missing values (NA, NaN or Inf) are not accepted.
twiceit | a 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 is FALSE.
kind | a character string. Indicates the kind of smoother. Must be one of the following: "3RS3R" "3RSS" "3RSR" "3R" "3" "S"
endrule | a character string. Specifies the end rule of smoothing at the boundary. Must be one of the following: "Tukey" "copy"
do.ends | a logical value. used for kind = "S" only. If TRUE, a process of splitting occurs at the boundary. By default, do.ends is FALSE

### Details

The kind of smoother as follows:

| 3 |  | a running median of length three.
| S |  | a process of splitting the peaks and valleys (that is, the sequences of two identical values surrounded by two higher or two lower values).
| 3R |  | a running median of three, repeated until there is no further change in the smoothed sequence.
| 3RS3R |  | a repeated running medians of S of the results from 3R until it reaches a convergence or four iterations.
| 3RSS |  | a repeated running splitting the peaks and valleys of the results from 3R until convergence or four iterations.
| 3RSR |  | a repeated running S and 3R of the results from 3R until it reaches a convergence or four iterations.

Value
returns an object of class "tukeysmooth" with the result and information about the smoother. If the input is a "ts" object, the class of the object is c("tukeysmooth", "ts")
References
Tukey, J. W. 1977. Exploratory Data Analysis. Reading, MA: Addison-Wesley Pub.
See Also
loess, lowess, supsmu.
Examples

    x <- c(1,5,6,4,7,7,1,2,1)
    smooth(x)
    smooth(x, twiceit = TRUE)
    smooth(x, kind = "3")

Package stats version 6.1.5-18
Package Index