# How can I average the variance extracted from different group of samples?

I have groups of samples, where each group has a different number of samples and a different mean. I also know the variance of each group of samples. I would like to compute a sort of "average" variance, that should be something like the mean of my variances.

If the groups had all the same number of units, I think I could simply average the variances of each group summing up the variances and dividing by the number of groups.

However my groups have different sizes and I should, somehow, keep this into account.

How can I proceed?

• Do you want a variance for some aggregated mean? Maybe look at the Horvitz–Thompson estimator. Commented Feb 9, 2023 at 10:27
• You have some good answers already, so this comment might be more useful for other people who find your question later: I think it's worth making sure you understand the purpose of what you are doing here, since "averaging the variance" might not mean what you hope it will mean. For example if everyone in group A scored 5 (so mean is 5 and variance is 0), everyone in group B scored 7 (mean 7, variance 0) and everyone in group C scored 9 (mean 9, variance 0), what would it mean to say the "average variance is 0"? It's certainly not meaningless, but it doesn't mean there's no variation at all! Commented Feb 10, 2023 at 1:21

The precise answer to your question depends on what are you going do to with it, but a possible answer could be to calculate the pooled variance. The poled variance is a method for estimating the variance of several different populations when the mean of each population may be different, but one may assume that the variance of each population is the same.

Suppose you have $$k$$ groups, the (corrected) sample variances $$s_1^2, \ldots,s_k^2$$ and the group size is $$n_1,\ldots, n_k$$. Then the pooled variance is

$$s_{pool}^2 =\frac{(n_1-1)s_1^2+\cdots+(n_k-1)s_k^2}{(n_1-1)+\cdots+(n_k-1)}.$$

Quoting from Wikipedia's page

If we can assume that the same phenomena are generating random error at every level of $$x$$, the above data can be “pooled” to express a single estimate of variance and standard deviation. In a sense, this suggests finding a mean variance or standard deviation among the five results above.

which, to me seems to answer what you are looking for.

• Thanks, it's exactly what I am looking for! Commented Feb 9, 2023 at 10:25

One logical approach is to meta-analyze the variance, you can then either look at the inference about the mean of studies/experiments/samples or about the prediction for a new unseen study (or any particular study, you've already seen). There's a vignette on this for the RBesT R package.

This is all based on the observation (see e.g. Schmidli et al. 2017) that - assuming a normal distribution for the data (at least after suitable transformation - the sampling distribution of the estimate of the (residual) variance of an group in a study with $$n$$ patients/samples follows a $$\Gamma(\nu/2, \nu/(2 \sigma^2))$$ distribution, where $$\sigma$$ is the true variance. We would typically use $$\nu = (n-1)$$ when the residual variance is from a linear model with just an intercept per group. Note that we use the parameterization of the $$\Gamma$$-distribution in terms of a shape and a rate parameter (sadly, there's many versions around). You can then assume that $$\log(\sigma_i)$$ for study $$i$$ varies across studies $$i=1,\ldots,I$$ according to e.g. a normal distribution.