6
$\begingroup$

Suppose we only have the following information:

  • A set of sample means : $\bar{x_1}$, $\bar{x_2}$ ... $\bar{x_k}$
  • The sample size used to calculated each sample mean: $n_1$, $n_2$ ....$n_k$
  • The population size from which each sample mean was taken: $N_1$, $N_2$ ....$N_k$
  • The sample variance of each mean: $Var(\bar{x_1})$, $Var(\bar{x_2})$ ... $Var(\bar{x_k})$
  • We do NOT have the raw data that were used to calculate the sample means

Given this information, I have seen that this information can be combined together to produce a weighted mean estimator:

1) Count Weighted Mean:

$$\bar{x_W} = \frac{\sum_{i=1}^{k} w_i \bar{x_i}}{\sum_{i=1}^{k} w_i}$$ $$w_i = n_i$$

$$Var(\bar{x_W}) = \frac{\sum_{i=1}^{k} w_i^2 Var(\bar{x_i})}{(\sum_{i=1}^{k} w_i)^2}$$

2) Variance Weighted Mean:

$$\bar{x_W} = \frac{\sum_{i=1}^{k} w_i \bar{x_i}}{\sum_{i=1}^{k} w_i}$$

$$w_i = \frac{1}{Var(\bar{x_i})}$$

$$Var(\bar{x_W}) = \frac{\sum_{i=1}^{k} w_i^2 Var(\bar{x_i})}{(\sum_{i=1}^{k} w_i)^2}$$

Note that in this case, it can be shown (using Lagrange Multipliers) that this weighting scheme (i.e. inverse variance) will produce the estimate with the lowest overall variance (https://en.wikipedia.org/wiki/Inverse-variance_weighting)

My Question: Suppose we are given the exact same information (i.e. sample size, population size, sample variance, no raw data) - but this time, we are provided with the sample medians instead of the sample means.

Is it still common practice to calculate "weighted median" estimators just as we did above? Or does this "ruin" the purpose of the median by "contaminating" all the medians with each other (i.e. influencing) - thus no longer a "true median"? In general, I am not sure if it is a good idea to combine medians like this together: does this combined estimator still have desired mathematical properties (e.g. asymptotic normality, consistency).

I am not sure how exactly the variance of this weighted median estimator will be calculated. I am considering using the weighted bootstrap in this situation (i.e. the probability of selecting an individual median is proportional to its weight) - but I am not sure if this is a statistically valid approach (e.g. Understanding the Weighted Bootstrap)

References:

$\endgroup$
12
  • 4
    $\begingroup$ Duplicate ? stats.stackexchange.com/questions/167977/weighted-median, stats.stackexchange.com/questions/162511/… $\endgroup$ Commented Aug 9, 2023 at 0:25
  • $\begingroup$ @kjetilbhalvorsen : thank you for your reply! I had consulted this question and the wikipedia page prior to posting my question .... I was hoping to learn more about this topic that are not discussed in the linked question (e.g. variance of weighted median, statistical properties of weighted median, etc.). this is why i posted my question. thank you so much! $\endgroup$
    – stats_noob
    Commented Aug 9, 2023 at 0:29
  • 1
    $\begingroup$ The question proceeds from a general title to a particular query about combining certain input. @Henry's answer deals nicely with the particular query; mine is really addressed only at the general title. imagining that future readers might echo the title without having the particular query. $\endgroup$
    – Nick Cox
    Commented Aug 9, 2023 at 10:33
  • 1
    $\begingroup$ @NickCox Well, I'm not a moderator and maybe only superficially aware of the policies here but up to now I had assumed that changing a title so that it better reflects the question asked is helpful (the author can change it back if they disagree, no?). Furthermore, as you yourself stated, the original title made us suspect a duplicate, which the question itself actually isn't, as far as I'm aware. $\endgroup$ Commented Aug 13, 2023 at 11:37
  • 1
    $\begingroup$ @NickCox Fair enough. I will not change the title back as I think the current one expresses much better what is asked in the question (and also I don't see immediately how to revert the change), however if you (or the OP) change it back I'll leave it as it then is. No battle to be expected. $\endgroup$ Commented Aug 13, 2023 at 12:42

3 Answers 3

9
$\begingroup$

No - your approach does not work without further assumptions.

For example in the counting case, if I told you that

  • Group A had a weight of $10\%$ and median $3$
  • Group B had a weight of $90\%$ and median $8$

all you can say is that the overall median is somewhere in $[3,8]$.

If the actual observations were as follows, the overall median would be $3$. Change the $42:48$ in group B to $32:58$ and the overall median becomes $8$. Intermediate overall medians are also possible.

Value  Frequency  Group
  2       42        B
  3       10        A
  8       48        B
$\endgroup$
9
$\begingroup$

This was an early answer reacting to the original title which began: Does the "Weighted Median" Exist?

How common it is overall I can't easily say, but applications are easy to mention: e.g. median income as calculated from incomes and weights.

Let's keep an example calculation trivial:

Income bins 1, 2, 3, 4 with weights 0.3, 0.4, 0.2, 0.1.

So cumulative weights are 0.3, 0.7, 0.9 and 1 and cumulative weight 0.5, which defines the position of the median, falls within bin 2, which is reported as the median.

Interpolation can be as fancy as you like, e.g. linear interpolation between bin limits, and so on.

In short, order the values, and scale weights to sum to 1. Then cumulative weight 0.5 defines the position of the median, the precise recipe depending on local tradition and personal taste.

The recipe can be extended to weighted quantiles.

Various common areas:

Data are released for geographic areas. We might even try to get a weighted median from area means and their weights.

Data are released only binned in some other way, e.g. to respect confidentiality, etc.

Incomes are top-coded, so there are no precise details released on the very richest people. In this case, means are out of the question except with strong assumptions, but medians might be tractable (and interesting and useful any way).

$\endgroup$
6
  • $\begingroup$ Thank you so much for your answer! Can we use similar weights as I described earlier (e.g. count based, variance based)? can the weighted bootstrap method be used here? does the weighted median have certain statistical properties? thank you so much! $\endgroup$
    – stats_noob
    Commented Aug 9, 2023 at 0:32
  • $\begingroup$ I guess you can use whatever weights make sense. Detailed properties and procedures are beyond my scope. Bootstrapping with weights would at best be a messier thing, I imagine, but it is beyond my experience. You need answers on that from people who have worked on it. $\endgroup$
    – Nick Cox
    Commented Aug 9, 2023 at 0:35
  • $\begingroup$ The geographical example does not work well. Eg: Suppose everyone in a state rates the president on a 0-10 scale, with mean ratings of 6, 6, and 2 in the state’s three districts. If each district is homogeneous, the president’s median rating in the state is a 6; if each district is a mix of people who rate the president 10 and people who rate the president 0, then the median rating in the state would be 0. So trying to calculate the median from the district means and populations can fail badly. $\endgroup$
    – Matt F.
    Commented Aug 10, 2023 at 1:59
  • $\begingroup$ @MattF Agreed. It's not always a good idea in practice if you don't have the original data. $\endgroup$
    – Nick Cox
    Commented Aug 10, 2023 at 6:55
  • $\begingroup$ Do you have any examples where the data are binned geographically and it is reasonable to estimate the median from the area means and weights? If not, I think that paragraph should be deleted from the answer. $\endgroup$
    – Matt F.
    Commented Aug 10, 2023 at 11:11
3
+50
$\begingroup$

Does the "Weighted Median" Exist?

Obviously it exists, you can take a median of medians. Using weighted medians is just an extension.

The more relevant question is whether it is useful to use a median of medians and to use weights.

Is it still common practice to calculate "weighted median" estimators just as we did above? Or does this "ruin" the purpose of the median by "contaminating" all the medians with each other (i.e. influencing) - thus no longer a "true median"?

If the sample medians are drawn from populations with the same distribution then the median of medians can be biased (just like a sample median can be biased), but it is consistent. The quantile of the sample medians will follow a beta distribution which approaches the 0.5 point when the sample sizes increase$^{*}$.

Using weights can improve the properties of the median of medians statistic if the different medians do not follow the same beta distribution.

Below is an example where we simulated the median of medians by using two times ten samples from different beta distributions (representing a sample of twenty medians each sampled based on different sample sizes) and combine them with different weights. It shows that there is an optimal weight.

simulations

set.seed(1)

sample = function(n=10, weights = c(1,2)) {
   x = rbeta(n,3,3)
   y = rbeta(n,10,10)
   standard = median(c(x,y))
   weighted = median(c(rep(x,weights[1]),rep(y,weights[2])))
   return(c(standard, weighted))
}


weights = matrix(c(1,2,
                   1,3,
                   1,4,
                   1,5,
                   2,3,
                   2,5,
                   3,4,        
                   3,5,
                   4,5),9, byrow = 1)
 

standard = rep(NA,9)
weighted = rep(NA,9)
k = 1:9

for (ki in k) {
  s = replicate(3*10^4,sample(10, weights = weights[ki,]))
  standard[ki] = var(s[1,])
  weighted[ki] = var(s[2,])
}

plot(weights[,1]/weights[,2],standard, ylim = range(c(standard,weighted)), xlab = "ratio of weights", ylab = "variance of statistic")
points(weights[,1]/weights[,2],weighted,col = 2) 

legend(0.2, 0.00145, c("standard","weighted"), col = c(1,2))

Whether this approach has been applied somewhere in practice or literature I do not know. But the above shows that in principle the weighted median of medians exists and can make sense.


$^*$ For continuous variables, the sample distribution of the median is $F_X^{-1}(U)$ with $U$ a beta distribution. So the sampling of the sample median is similar to sampling from that beta distribution and then applying the quantile function $F^{-1}$. See for more: Is the median of a very large number of medians always equal to the true median and Central limit theorem for sample medians

$\endgroup$
9
  • $\begingroup$ @ Sextus Empiricus: thank you so much for your answer! Just some questions I had about what you wrote: $\endgroup$
    – stats_noob
    Commented Aug 12, 2023 at 23:58
  • $\begingroup$ 1) "The quantile of the medians will follow a beta distribution which approaches the 0.5 point when the sample sizes increase." Can you pleas explain why this is? Do you have any references on this? I have tried to search this on the internet and I keep getting references on how to take the median of a beta distribution - but I don't think this is what you are referring to. $\endgroup$
    – stats_noob
    Commented Aug 13, 2023 at 0:00
  • $\begingroup$ 2) Are there any recommended methods for choosing the weights? When reading about the weighted mean of means, it seems like two popular methods to select weights were based on the number of points used to calculate each mean - or based on the variance of each individual mean. Do you think similar logic could be used to select the weights here? $\endgroup$
    – stats_noob
    Commented Aug 13, 2023 at 0:03
  • $\begingroup$ 3) "If the sample medians are drawn from populations with the same distribution then the median of medians will be biased (just like a sample median can be biased), but it is consistent" . Can you please explain this or provide any references? I.e. why is the median of the medians biased, why is the median of the medians consistent? $\endgroup$
    – stats_noob
    Commented Aug 13, 2023 at 0:08
  • $\begingroup$ Please note: I posted these questions in a new question stats.stackexchange.com/questions/623853/… $\endgroup$
    – stats_noob
    Commented Aug 13, 2023 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.