# DGB
## Median from One Sample
ci.median.os <- function(alpha, y) {
# Computes confidence interval for a population median
# Arguments:
# alpha: alpha level for 1-alpha confidence
# y: vector of sample scores
# Values:
# median, SE, lower limit, upper limit
n <- length(y)
y <- sort(y)
z <- qnorm(1 - alpha/2)
c1 <- round((n - z*sqrt(n))/2)
if (c1 < 1) {c1 = 1}
median <- median(y)
L <- y[c1]
U <- y[n - c1 + 1]
a <- round((n + 1)/2 - sqrt(n))
if (a < 1) {a = 1}
L1 <- y[a]
U1 <- y[n - a + 1]
p <- pbinom(a - 1, size = n, prob = .5)
z0 <- qnorm(1 - p)
se <- (U1 - L1)/(2*z0)
out <- t(c(median, se, L, U))
colnames(out) <- c("Median", "SE", "LL", "UL")
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.