This function detects outliers in a numeric vector using the MAD (Median Absolute Deviation) method. It calculates the median and the MAD, and determines the boundaries for outliers based on the median and the selected number of MADs.
Usage
isOutlier(
x,
nmads = 2.5,
constant = 1.4826,
type = c("both", "lower", "higher")
)
Arguments
- x
a numeric vector.
- nmads
the number of median absolute deviations (MADs) from the median to define the boundaries for outliers. The default value is 2.5.
- constant
a constant factor to convert the MAD to a standard deviation. The default value is 1.4826, which is consistent with the MAD of a normal distribution.
- type
the type of outliers to detect. Available options are "both" (default), "lower", or "higher". If set to "both", it detects both lower and higher outliers. If set to "lower", it detects only lower outliers. If set to "higher", it detects only higher outliers.