Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


complexlm (version 1.1.2)

mad: Median Absolute Deviation, compatible with complex variables

Description

Median absolute deviation, adapted to operate on complex data as well as numeric. In the later case it simply calls stats::mad(). For complex x it uses the geometric median, pracma::geo_median(), as the center, then returns the median absolute difference between center and each element of x, multiplied by constant.

Usage

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

Value

numeric. The median absolute deviation (MAD) from center.

Arguments

x

a numeric or complex vector.

center

optional, numeric or complex. The center about which to calculate MAD. Defaults to median for numeric, and geo_median for complex.

constant

a constant by which to multiply the median absolute deviation from center. Default is 1.4826, which is the inverse of the 3/4 quantile for the normal distribution.

na.rm

logical. Should NAs be removed from x before calculating.

low

logical. If TRUE, compute the "lo-median", i.e., for even sample size, do not average the two middle values, but take the smaller one. Not used if x is complex.

high

logical. If TRUE, compute the "hi-median", i.e., take the larger of the two middle values for even sample size. Not used if x is complex.

See Also

median.complex, stats::mad

Examples

Run this code
set.seed(4242)
n <- 8
foo <- complex(real = rnorm(n), imaginary = rnorm(n))
mad(foo)

Run the code above in your browser using DataLab