1

I'm trying to calculate a weighted variance for a group of studies in a meta analysis for which I have individual means and variances:

variance    #available variance values for studies
 [1] 0.705600       NA 2.102500 0.672400 0.980100 0.494209       NA 5.317636 
4.431025       NA       NA
[12] 0.184900


number2    #patient numbers for studies with variance
 [1]  16  NA  52  15  42  22  NA 114  40  NA  NA  48

Do I need to use a weighted variance function like wtd.var from Hmisc? Or can I simply weight the variance values according to the sample size in a similar way to weighted means?

When I use the wtd.var function on the above data I get a weighted variance 2.35 which is higher than the variance in any of the studies. Intuitively I expected the weighted variance to be somewhere between the min and max values of the individual study variances.

Thanks so much in advance for the help, I'm new to R and statistics and really struggling!

Ferdi
  • 11
  • 2

1 Answers1

0

The mean of the variances gives a “typical” or “expected” variance in light of  your data.  If you want the mean variance, with the mean weighted by number of patients, then request

    # I renamed your variables a bit:
    variances <- c(0.705600, NA, 2.102500, 0.672400, 0.980100, 0.494209,  NA, 5.317636, 4.431025, NA, NA, 0.184900)
    n.pts <- c(16,  NA,  52,  15,  42,  22,  NA, 114,  40,  NA,  NA,  48)

    wtd.mean(x = variances, weights = n.pts)
    [1] 2.793894

As you anticipated, the (weighted) mean variance is toward the center of the source value range.

The variance of the variances, in contrast, describes the spread of your variances, not their central tendency (second rather than first moment of the distribution).  There is wide diversity among the variances, which the calculation captures.

    wtd.var(x = variances, weights = n.pts)
    [1] 4.530746

The distinction might be more obvious if we recenter the data, so the mean and variance of the distribution differ more.

    variances <- variances + 20
    wtd.mean(variances, weights = n.pts)
    [1] 22.79389
    wtd.var(variances, weights = n.pts)
    [1] 4.530746
InColorado
  • 308
  • 2
  • 12