pMedian: pMedian

View source: R/pMedian.r

pMedianR Documentation

pMedian

Description

Pseudomedian

Usage

pMedian(x, na.rm = FALSE)

Arguments

x

a numeric vector

na.rm

set to TRUE to exclude NAs before computing the pseudomedian

Details

Uses fast Fortran code to compute the pseudomedian of a numeric vector. The pseudomedian is the median of all possible midpoints of two observations. The pseudomedian is also called the Hodges-Lehmann one-sample estimator. The Fortran code is was originally from JF Monahan, and was converted to C++ in the DescTools package. It has been converted to Fortran 2018 here.

Value

a scalar numeric value

See Also

https://dl.acm.org/doi/10.1145/1271.319414, https://www4.stat.ncsu.edu/~monahan/jul10/

Examples

x <- c(1:4, 10000)
pMedian(x)
# Compare with brute force calculation and with wilcox.test
w <- outer(x, x, '+')
median(w[lower.tri(w, diag=TRUE)]) / 2
wilcox.test(x, conf.int=TRUE)

harrelfe/Hmisc documentation built on Nov. 21, 2024, 3:47 p.m.