mad
Robust Estimates of Scale

Description

Returns a robust scale estimate of the data. By default, the median is taken as the center of the data and the estimate is scaled to be consistent with the standard deviation of the Gaussian model.

Usage

mad(x, center = median(x), constant = 1.4826, na.rm = FALSE, 
    low = FALSE, high = FALSE) 

Arguments

x a vector of numeric data. Missing values (NA) are allowed.
center location parameter to be subtracted from each element of x before computing the scale estimate.
a number that multiplies the median of the absolute values. The default value makes the estimate consistent with the standard deviation of the Gaussian model.
na.rm a logical flag; indicates whether missing values should be removed before computations.
low, high logical flags; if low is TRUE, the low median is used; if high is TRUE the high median is used; if both are FALSE, the central median is used. Either low or high can be TRUE.

Details

If na.rm is FALSE, then missing values in the data cause the final result to be NA. Missing values are removed before computations are performed when na.rm is TRUE.
The MAD scale estimate has a 50% breakdown point. With "contaminated" data, the MAD generally has small bias when compared to other scale estimators.
Value
a single value that is a robust estimate of scale. The default estimate is consistent for the standard deviation of Gaussian data.
References
Hampel, F. R., et al. 1986. Robust Statistics: The Approach Based on Influence Functions. New York, NY: Wiley.
Hoaglin, D. C., Mosteller, F. and Tukey, J. W., editors. 1983. Understanding Robust and Exploratory Data Analysis. New York, NY: Wiley.
See Also
var.
Examples
mad(rnorm(200))  # approximately equal to 1

x <- c(1, 2, 5, 72, 3, 5, 8, 34, NA) mad(x, center = 7, na.rm = TRUE, low = TRUE)

mad(c(5, 3, 5, 6, 7, 4, 3, 12), low = TRUE) # [1] 1.4826 mad(c(5, 3, 5, 6, 7, 4, 3, 12), high = TRUE) # [1] 2.9652

Package stats version 6.1.1-7
Package Index