confIntMedian: Exact confidence interval for median of a sample based on...

View source: R/confIntMedian.R

confIntMedianR Documentation

Exact confidence interval for median of a sample based on order statistics

Description

Given a sample X_1, ..., X_n, this function computes an exact confidence interval for the median of the sample based on the binomial distribution.

Usage

confIntMedian(x, conf.level = 0.95)

Arguments

x

Numeric vector of observations.

conf.level

Confidence level for confidence interval.

Value

data.frame containing the median and the confidence interval.

Author(s)

Kaspar Rufibach
kaspar.rufibach@gmail.com

References

Lehmann, E. (1975). Nonparametrics: Statistical Methods Based on Ranks. Holden-Day, 182–183.

A worked out example (in Section 5, p. 38) can be found in

Altman, D.G., Machin, D., Bryant, T.N., Gardner, M.J.(2000). Statistics with confidence. University Press Belfast.

Examples


# generate random sample
set.seed(1977)
x <- rnorm(40)

# compute CI for median
confIntMedian(x = x, conf.level = 0.95)

# data from Altman (2000), p. 38
x2 <- c(66, 71.2, 83, 83.6, 101, 107.6, 122, 143, 160, 177, 414)
confIntMedian(x = x2, conf.level = 0.95)


felix-hof/biostatUZH documentation built on Sept. 27, 2024, 1:48 p.m.