mad: Median Absolute Deviation

Description Usage Arguments Value See Also Examples

Description

Compute the median absolute deviation for a vector, dispatching only on the first argument, x.

NOTE: This man page is for the mad S4 generic function defined in the BiocGenerics package. See ?stats::mad for the default method (defined in the stats package). Bioconductor packages can define specific methods for objects not supported by the default method.

Usage

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

Arguments

x, center, constant, na.rm, low, high

See ?stats::mad.

Value

See ?stats::mad for the value returned by the default method.

Specific methods defined in Bioconductor packages should behave as consistently as possible with the default method.

See Also

Examples

1
2
3
mad
showMethods("mad")
selectMethod("mad", "ANY")  # the default method

Example output

Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

standardGeneric for "mad" defined from package "BiocGenerics"

function (x, center = median(x), constant = 1.4826, na.rm = FALSE, 
    low = FALSE, high = FALSE) 
standardGeneric("mad")
<environment: 0x38db108>
Methods may be defined for arguments: x
Use  showMethods("mad")  for currently available ones.
Function: mad (package BiocGenerics)
x="ANY"

Method Definition (Class "derivedDefaultMethod"):

function (x, center = median(x), constant = 1.4826, na.rm = FALSE, 
    low = FALSE, high = FALSE) 
{
    if (na.rm) 
        x <- x[!is.na(x)]
    n <- length(x)
    constant * if ((low || high) && n%%2 == 0) {
        if (low && high) 
            stop("'low' and 'high' cannot be both TRUE")
        n2 <- n%/%2 + as.integer(high)
        sort(abs(x - center), partial = n2)[n2]
    }
    else median(abs(x - center))
}
<bytecode: 0x38f7a28>
<environment: namespace:stats>

Signatures:
        x    
target  "ANY"
defined "ANY"

BiocGenerics documentation built on April 17, 2021, 6:01 p.m.