thanks for the quick reply concerning my query about
CIs for the median.
Brian Ripley points out the the "Hinge" is a definition
by Tukey, which is more-or-less the quartile (which itself
is not quite fully described). The correct definition should
be in the EDA book by Tukey.
Any difference between the "Hinges" and Quartiles
should be small, except in small samples.
Luc Wouters (wouters@janbe.jnj.com) sent me the following
function:
----------Message from Luc Wouters-------------------------
A distribution-free confidence interval on the median assuming only iid is
based on the order statistics and the binomial distribution. See Lehmann
(Nonparametrics: Statistical Methods Based on Ranks, Holden-Day, 1975, p.
182-183). The following S-Plus function can be used to set up such a 95 %
distribution-free confidence interval on the median:
"conf.med"<-function(x)
{
v <- sort(x, na.last = NA)
n <- length(x)
if(n > 0) {
m <- median(x)
i <- qbinom(0.025, n, 0.5)
if(i > 0)
r <- c(m, v[i], v[n - i + 1])
else r <- c(m, NA, NA)
}
else r <- c(NA, NA, NA)
r <- as.data.frame(list(median = r[1], lower = r[2], upper = r[3]))
class(r) <- "table"
r
}
conf.med(1:6)
>$median:
>[1] 3.5
>$lower:
>[1] 1
>$upper:
>[1] 6
Notice that a 95 % confidence interval can be obtained only when n > 5:
conf.med(1:5)
>$median:
>[1] 3
>$lower:
>[1] NA
>$upper:
>[1] NA
When the data are differences, then these C.I.'s are related to the sign
test. Notice that these C.I. have the disadvantage of being rather
conservative.
--------------------End of Message from Luc Wouters---------------------
Finally, answering my question whether there are better ways to do this,
Brian Ripley points out that robust estimators (available in S-PLUS)
might usually do a much better job than the median. A bootstrap approach
would then give probably better CIs for such estimators.
Thanks to all for helping me out on this.
Marcel
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news