# re: [S] Summary about CIs for Median

Scott.Chasalow@USERS.PV.WAU.NL
Fri, 30 Oct 1998 18:41:11 +0100

On Wed Oct 28 16:45:02 1998,
<marcel.baumgartner@rdls.nestle.com> wrote:
>CIs for the median.
...
>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(1:6)
>>\$median:
>>[1] 3.5
>>\$lower:
>>[1] 1
>>\$upper:
>>[1] 6
...
>
>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.

I have an SPLUS function for computing C.I.'s for any quantile, based
on the same ideas as is Luc Wouter's function. Luc's function gives an
approximately symmetric 95% CI for the median. Besides giving C.I.'s for
other
quantiles and for a specified range of coverage probabilities, I allow the
user to
compute many different confidence intervals, perhaps with only slightly
different
coverage probabilities, different lengths, symmetric or not, and so on. You
can
then look at them all and pick the one you prefer; the function can sort them
or

If anyone would like a copy of this function, please drop me an email. The
code,
including that for three local support functions, is too long to send to the
whole
list.

Here are a couple of examples:

# A CI for the median
> ci.quantile(x = 1:6, p = 0.5, level.range = c(0.945, 1))

Lower Upper Length Level
[1,] 1 6 5 0.96875
attr(, "percentile"):
50%
3.5

# Various CIs for the median
> ci.quantile(x = 1:6, p = 0.5, level.range = c(0, 1))

Lower Upper Length Level
[1,] 1 6 5 0.968750
[2,] 1 5 4 0.875000
[3,] 2 6 4 0.875000
[4,] 2 5 3 0.781250
[5,] 1 4 3 0.640625
[6,] 3 6 3 0.640625
[7,] 2 4 2 0.546875
[8,] 3 5 2 0.546875
[9,] 1 3 2 0.328125
[10,] 3 4 1 0.312500
[11,] 2 3 1 0.234375
attr(, "percentile"):
50%
3.5

# Various CIs for the upper quartile
> ci.quantile(x = 1:6, p = 0.75, level.range = c(0,1))

Lower Upper Length Level
[1,] 1 6 5 0.8217773
[2,] 2 6 4 0.8173828
[3,] 3 6 3 0.7844238
[4,] 4 6 2 0.6525879
[5,] 1 5 4 0.4658203
[6,] 2 5 3 0.4614258
[7,] 3 5 2 0.4284668
[8,] 4 5 1 0.2966309
[9,] 1 4 3 0.1691895
[10,] 2 4 2 0.1647949
[11,] 3 4 1 0.1318359
attr(, "percentile"):
75%
4.75

# Various CIs for the lower quartile
> ci.quantile(x = 1:6, p = 0.25, level.range = c(0, 1))

Lower Upper Length Level
[1,] 1 6 5 0.8217773
[2,] 1 5 4 0.8173828
[3,] 1 4 3 0.7844238
[4,] 1 3 2 0.6525879
[5,] 1 2 1 0.3559570
attr(, "percentile"):
25%
2.25
Cheers,
Scott
=========================================
Scott.Chasalow@users.pv.wau.nl

Wageningen Agricultural University
Laboratory of Plant Breeding
P.O. Box 386
6700 AJ Wageningen
THE NETHERLANDS

http://www.spg.wau.nl/pv/staff/Chasal_S.htm
==========================================
-----------------------------------------------------------------------
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