From: Oliver Duerr <Oliver.Duerr_at_genedata.com>

Date: Wed 21 Sep 2005 - 02:10:48 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Sep 21 02:13:31 2005

Date: Wed 21 Sep 2005 - 02:10:48 EST

Dear all,

I found a strange result using R's weightedMedian function.
Consider the following:

*> x <- c (0.2, 0.3, 0.5)
**> w <- c (1,1,2)
*

> weightedMedian(x,w)

> 0.3666

In cases like above, when the weights are integers, one could argue that
the weighted

median should be the same as the standard median with the elements
repeated according to their weights. This is trivially true for the mean.
In the example above, we simply double the occurrence of the 0.5 entry

> x1 <- c(0.2, 0.3, 0.5, 0.5)

> median(x1) 0.4

Does anyone know the answer to that inconsistency?
It must have to do with the interpolated version.
If you switch of the interpolation you get:

> weightedMedian(x,w,interpolate=FALSE)

*> 0.4
*

However, I prefer the interpolated version since it is continuous with respect to the weights. Is there a interpolated version of the weightedMedian which does not show this inconsistency?

All the best,

Oliver

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Sep 21 02:13:31 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:40:14 EST
*