detect_outliers_mad {topolow} | R Documentation |
Detect Outliers Using Median Absolute Deviation
Description
Detects outliers in numeric data using the Median Absolute Deviation (MAD) method. This robust method is less sensitive to extreme values than standard deviation and works well for non-normally distributed data.
Usage
detect_outliers_mad(data, k = 3, take_log = FALSE)
Arguments
data |
Numeric vector of values to analyze |
k |
Numeric threshold for outlier detection (default: 3). Points more than k MADs from median are considered outliers. |
take_log |
Logical. Whether to log transform data before (and only for) outlier detection (default: FALSE) |
Details
The function:
Calculates median and MAD of the data
Uses scaled MAD (constant = 1.4826) for normal distribution consistency
Identifies points > k MADs from median as outliers
Returns both outlier mask and summary statistics
MAD scaling constant 1.4826 is calculated as 1/Phi^(-1)(3/4), where Phi is the standard normal CDF. This makes MAD consistent with standard deviation for normal distributions.
Value
A list containing:
outlier_mask |
Logical vector indicating outliers |
stats |
List containing:
|