Content Disclaimer
Copyright @2020.
All Rights Reserved.
StatsToDo : Combine Means and SDs Into One Group Program

Links : Home Index (Subjects) Contact StatsToDo

Introduction Javascript Program R Code
This page is a simple utility to combine multiple groups of n, mean, and SD into a single group. Two algorithms are offered, both producing the same results, but using different formulae.

Decomposition of means and Standard Deviation:

  • For each group :
    • Σx = mean * n;
    • Σx2 = SD2(n-1)+((Σx)2/n)
  • The values are then added together
    • tn = sum of all (n)
    • tx = sum of all Σx
    • txx = sum of all Σx2
  • The combine calculations are
    • Combined n = tn
    • Combined mean = tx / tn
    • Combine SD = sqrt((txx-tx2/tn) / (tn-1))
  • When calculated the results from the example data should look like the following
    nmeanSD    Σx Σx2
Algorithm described by Cochrane

Cochrane's formula combines two groups of n, mean, and SD (n1, m1, s1 and n2, m2, s2) with the following calculations

  • Combined n = n1 + n2
  • Combined mean = (n1*m1 + n2*m2) / (n1 + n2)
  • Combined Standard Deviation = sqrt(((n1-1)*s1*s1 + (n2-1)*s2*s2 + n1 * n2 / (n1 + n2) * (m1*m1 + m2*m2 - 2 * m1 * m2)) / (n1 + n2 -1));
  • When more tha 2 groups are to be combined, the first two groups are combined first, the results are then combined with the third group, then sequentiaaly with each subsequent group.
  • When calculated the results from the example data should look like the following
    Individual Groups  Combined with previous Groups
    nMeanStandard DeviationnMeanStandard Deviation
    Row 11011.82.41011.82.4
    Row 22015.33.23014.13333.3634
    Row 3158.44.14512.22224.5028

    Please Note :

    Combining n, mean, SD from different groups must be used with care, as the statistical assumption is that all the groups are merely sub-samples of a single group, and combining them merely restore them back into the original single group.

    In many cases this assumption is faulty, as the groups may be from different populations, and sampled under different environments. It is much safer therefore to combine groups using the meta-analysis algorithm, using the Random Effect Model, available in the Meta-analysis for Comparing Two Unpaired Groups Program Page , using the mean and Standard Error of the mean for each group.

    The Standard Error of the mean is calculated as SE = SD / sqrt(n) of each group.

    After combining them using the Random Effect Model, the Standard Deviation can be recalculated as SD = SE * sqrt(tn), where tn is the sum of sample sizes from all the groups. The results should look like the following. I have made bold calculations of SE = SD / sqrt(n) before meta-analysis, and from SD = SE x sqrt(n) after meta-analysis

    Fixed Effect Model4512.62993.13410.4672
    Random Effect Model4511.897512.66841.8885

    References :

    Altman DG, Machin D, Bryant TN and Gardner MJ. (2000) Statistics with Confidence Second Edition. BMJ Books ISBN 0 7279 1375 1. p. 28-31

    Higgins JPT, Li T, Deeks JJ (editors). Chapter 6: Choosing effect measures and computing estimates of effect. In: Higgins JPT, Thomas J, Chandler J, Cumpston M, Li T, Page MJ, Welch VA (editors). Cochrane Handbook for Systematic Reviews of Interventions version 6.0 (updated July 2019). Cochrane, 2019. Available from (table 6.5.2a)