Description Usage Arguments Details Value Author(s) References Examples
Remove outliers from vector using a MAD value as cutoff.
1 | is.outlier(x, mcut = 6.2)
|
x |
Vector of data points to remove outliers from |
mcut |
Number of MADs a data point needs to be from the median to be considered an outlier, default is 6.2 |
See: Davies, P.L. and Gather, U. (1993). "The identification of multiple outliers" (with discussion) J. Amer. Statist. Assoc., 88, 782-801.
A vector of same length as "x"
with outliers changed to NA.
Greg Ziegler
Davies, P.L. and Gather, U. (1993).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | set.seed(1)
x <- rnorm(100)
x <- c(-10, x, 10)
y <- is.outlier(x)
summary(x)
summary(y)
## The function is currently defined as
function (x, mcut = 6.2)
{
y <- na.omit(x)
lims <- median(y) + c(-1, 1) * mcut * mad(y, constant = 1)
for (j in 1:length(x)) {
if (is.na(x[j]) | x[j] < lims[1] | x[j] > lims[2]) {
x[j] <- NA
}
}
return(x)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.