Different Ways to Calculate the Pooled Means I have the following question about the properties of individual means vs. pooled means. To illustrate my example, I will use the R programming language.
Suppose we have measurements from two different groups :
group_1 = rnorm(100,10,5)
group_2 = rnorm(50, 12, 8)

From here, we can calculate the pooled means two different ways:
Method 1:
#pooled mean method 1:

mean(mean(group_1) + mean(group_2))

 23.76851

Method 2:
#pooled mean method 2 (sorry, bad way of doing this):

d1 = data.frame(group_1)
d2 = data.frame(group_2)
colnames(d2)[colnames(d2) == 'group_2'] <- 'group_1'

d3 = rbind(d1,d2)
colnames(d3)[colnames(d3) == 'group_1'] <- 'pooled'

mean(d3$pooled)

 11.28023

My Question: Obviously, these two means are largely different - but are there any situations where it might be more favorable to prefer using one of these means compared to the other one?
For example, instead of the means, suppose you wanted to calculate the "pooled" 80th percentiles:
Method 1:
mean(quantile(group_1, 0.8) + quantile(group_2, 0.8))

34.43544

Method 2:
quantile(d3$pooled, 0.8)

   80% 
15.83668 

Would the same statistical properties about the different mean estimators still apply to these pooling methods?
Thanks!
 A: If your have 2 groups with means $\bar X_i$ and sizes $n_i,$ for $ i = 1,2,$ then the mean of the two groups combined is $$\bar X_c = (n_1\bar X_1 +n_2\bar X_2)/(n_1+n_2).$$ If you know the two group means and sample sizes, then this method does not require you to have the two original samples.
Demonstration in R:
set.seed(2021)
x1 = rnorm(10, 100, 15)
x2 = rnorm(20, 120, 20)

# Two ways to get the mean of the two groups combined 
# [formula and concatenation].

ac = (length(x1)*mean(x1) + length(x2)*mean(x2)) / 
       (length(x1)+length(x2))
ac
[1] 115.8537

mean(c(x1, x2))  # mean of concatenation
[1] 115.8537

By contrast...
# One way to get the median of the two groups combined:

median(c(x1, x2))
[1] 113.6022

A formula analogous to the one above for means does not work for medians (or other quantiles). [as below]. To get the the median of two groups combined, you need to concatenate the two groups to make the combined group and then find the median of the two groups combined [as above].
(length(x1)*median(x1) + length(x2)*median(x2)) / 
       (length(x1)+length(x2))
[1] 115.1819  # wrong median for groups combined

