Weight the groups

Combine totals correctly and see how changing group proportions can reverse a comparison.

Weight a mean by its group size

One group has 2 observations with mean 10; another has 8 with mean 20. Their totals are 20 and 160, so the combined mean is 180/10 = 18.

Averaging the two means gives 15, which gives the groups equal weight despite their different sizes. Multiply each mean by its group size, add the totals, then divide by the total count.

28× 10× 20(2 × 10 + 8 × 20)/10 = 18
The bar widths represent 2 and 8 observations, not equal group weights.

Read the rest as a member

You are reading the opening. Members read every lesson and guide in full. A free account reads the first lesson in each subject in full.

You are reading the opening. Your free account reads the first lesson in each subject in full. Members read every lesson and guide in full.

First lesson in this subject: Read data before calculating

Have an account? Sign in here.

The code lasts ten minutes and works once.