pMedian.Rd
Pseudomedian
pMedian(x, na.rm = FALSE)
a scalar numeric value
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.
x <- c(1:4, 10000)
pMedian(x)
#> [1] 3
# Compare with brute force calculation and with wilcox.test
w <- outer(x, x, '+')
median(w[lower.tri(w, diag=TRUE)]) / 2
#> [1] 3
wilcox.test(x, conf.int=TRUE)
#>
#> Wilcoxon signed rank exact test
#>
#> data: x
#> V = 15, p-value = 0.06
#> alternative hypothesis: true location is not equal to 0
#> 95 percent confidence interval:
#> 1 10000
#> sample estimates:
#> (pseudo)median
#> 3
#>