View source: R/biweight_scale.R
| biweight_scale | R Documentation |
This function computes the biweight scale, a robust measure of scale or dispersion for a numeric vector. The biweight scale is less sensitive to outliers than the sample standard deviation.
biweight_scale(
x,
loc = NULL,
c = 9,
reduced = FALSE,
drop_na = FALSE,
drop.na = deprecated()
)
x |
A numeric vector. |
loc |
The location about which the scale is computed (default: median of |
c |
A numeric value specifying the tuning constant for the biweight estimator ( |
reduced |
A logical value specifying whether the sample size, n, should be reduced to the number of non-rejected values. If |
drop_na |
A logical value indicating whether to remove missing values ( |
drop.na |
The biweight scale is the square root of the biweight midvariance:
\zeta = \frac{\sqrt{n \sum_{|u_i|<1} (x_i - M)^2 (1 - u_i^2)^4}}
{\left| \sum_{|u_i|<1} (1 - u_i^2)(1 - 5u_i^2) \right|},
\quad u_i = \frac{x_i - M}{c \cdot \mathrm{MAD}}
where M is the location (the median by default) and MAD is the
(unscaled) median absolute deviation. For normally distributed data the
biweight scale is a consistent estimator of the standard deviation.
The biweight scale of x.
Christian L. Goueguel
Mosteller, F., and Tukey, J. W. (1977). Data Analysis and Regression: A Second Course in Statistics. Addison-Wesley, pp. 203-209.
Beers, T.C., Flynn, K., Gebhardt, K., (1990). Measures of location and scale for velocities in clusters of galaxies - A robust approach. The Astronomical Journal, 100:32-46.
data(forageLIBS)
# iron contents (mg/kg): a few samples are far above the others
fe <- forageLIBS$Fe[!is.na(forageLIBS$Fe)]
c(sd = stats::sd(fe), mad = stats::mad(fe), biweight = biweight_scale(fe))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.