Compute the robust scale estimator \(S_n\), an efficient alternative to the MAD.

Sn(x, constant = 1.1926, finite.corr = missing(constant), na.rm = FALSE)

s_Sn(x, mu.too = FALSE, ...)

Arguments

x

numeric vector of observations.

constant

number by which the result is multiplied; the default achieves consisteny for normally distributed data.

finite.corr

logical indicating if the finite sample bias correction factor should be applied. Default to TRUE unless constant is specified.

na.rm

logical specifying if missing values (NA) should be removed from x before further computation. If false as by default, and if there are NAs, i.e., if(anyNA(x)), the result will be NA.

mu.too

logical indicating if the median(x) should also be returned for s_Sn().

...

potentially further arguments for s_Sn() passed to Sn().

Value

Sn() returns a number, the \(S_n\) robust scale estimator, scaled to be consistent for \(\sigma^2\) and i.i.d. Gaussian observations, optionally bias corrected for finite samples.

s_Sn(x, mu.too=TRUE) returns a length-2 vector with location (\(\mu\)) and scale; this is typically only useful for covOGK(*, sigmamu = s_Sn).

Details

............ FIXME ........

References

Rousseeuw, P.J. and Croux, C. (1993) Alternatives to the Median Absolute Deviation, Journal of the American Statistical Association 88, 1273–1283.

See also

mad for the ‘most robust’ but much less efficient scale estimator; Qn for a similar more efficient but slower alternative; scaleTau2.

Author

Original Fortran code: Christophe Croux and Peter Rousseeuw rousse@wins.uia.ac.be.
Port to C and R: Martin Maechler, maechler@R-project.org

Examples

x <- c(1:10, 100+1:9)# 9 outliers out of 19
Sn(x)
#> [1] 11.2671
Sn(x, c=1)# 9
#> [1] 9
Sn(x[1:18], c=1)# 9
#> [1] 9
set.seed(153)
x <- sort(c(rnorm(80), rt(20, df = 1)))
s_Sn(x, mu.too=TRUE)
#> [1] -0.2154659  1.1127858

(s <- Sn(c(1:4, 10, Inf, NA), na.rm=TRUE))
#> [1] 3.552755
stopifnot(is.finite(s), all.equal(3.5527554, s, tol=1e-10))