weighted_mad {robsurvey}R Documentation

Weighted Median Absolute Deviation from the Median (MAD)

Description

Weighted median of the absolute deviations from the weighted median

Usage

weighted_mad(x, w, na.rm = FALSE, constant = 1.482602)

Arguments

x

[numeric vector] data.

w

[numeric vector] weights (same length as x).

na.rm

[logical] indicating whether NA values should be removed before the computation proceeds (default: FALSE).

constant

[double] constant scaling factor to make the MAD a consistent estimator of the scale (default: 1.4826).

Details

The weighted MAD is computed as the (normalized) weighted median of the absolute deviation from the weighted median; see weighted_median. The weighted MAD is normalized to be an unbiased estimate of scale at the Gaussian core model. If normalization is not wanted, put constant = 1.

Value

Weighted median absolute deviation from the (weighted) median

See Also

Overview (of all implemented functions)

Examples

head(workplace)

# normalized weighted MAD (default)
weighted_mad(workplace$employment, workplace$weight)

# weighted MAD (without normalization)
weighted_mad(workplace$employment, workplace$weight, constant = 1)

[Package robsurvey version 0.6 Index]