aug_median: Centre weighted mean

Description Usage Arguments Details Examples

View source: R/augmented_median.R

Description

Offering a continuous link between median and arithmetic mean

Usage

1
aug_median(x, p = 1, rank = FALSE, na.rm = FALSE)

Arguments

x

numeric vector

p

positive numeric narrowness of the weight. 1 gives triangular weighting. Higher values gives narrower weights, approching meadian, lower values gives broader weights, approaching arithmetic mean

rank

logical. Should should ranks or numeric values determine relative weights?

na.rm

logical. Should missing values be removed?

Details

A weighted arithmetic mean is calculated over the input vector, where most weight is given to the median value(s), and monotonically less towards either extreme. Faloff depends on p, with small values resulting in a gentler falloff and less difference between minimum and maximum weights.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- c(0, 8, 8, 8, 9)

aug_median(x)

# 0 and 9 are considered equidistant from 8
aug_median(x, rank=TRUE)

# Nearly a point weight placed at the median
aug_median(x, 100)
median(x)

# Nearly uniform weights
aug_median(x, 0.001)
mean(x)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.