# Z - Score between average scores

I have a test that gives students a score between 0 and 10. Students can be black, white, asian or hispanic. I want to compare the average score of each race against the overall average, and I want to compare pairwise averages e.g. Average score of Black candidates vs Average Score of White candidates. To do this comparison, I would like to calculate the Z-score.

Is this the correct way to do so:

(Average Score of Black students - Average Score of White Students) / (Standard deviation of test scores)?


My main concern is with the denominator. I don't know if using the standard deviation of test scores applies when I compare averages?

• My main concern is with an analysis of students' test scores as a function of a single variable, ethnicity, and none of the other variables that have an effect on educational achievement, according to tons of evidence. These concerns aside, a good way to such pairwise comparisons is to model your data with a regression of test scores on ethnicity and then look at contrasts. In R you can do that straightforwardly with emmeans. May 6, 2022 at 16:07
• You don't really want to compute a z-score. This is a setting for Analysis of Variance with planned post-hoc tests, equivalent to the recommendation by @dipetkov.
– whuber
May 6, 2022 at 16:08
• Thank you for your responses! Doing further reading, the general consensus I see is that I shouldn't use a Z-score to compare sub-groups within the overall population. The main use for a z-score is to compare the difference between one sample and the overall. However I'm not sure as to why?
– YYH
May 6, 2022 at 16:25
• I share @dipetkov's lack of enthusiasm for this project. But there is a an appropriate procedure in R for comparing group sample means. // Notice that z scores are not involved. // Especially if sample sizes are small, results should be interpreted very carefully. May 6, 2022 at 17:34

Here is a simple analysis of means, which takes into account that different categories may have different variances. Suppose your data are as shown below:

set.seed(2022)
x1 = rnorm(10, 5, 1)
x2 = rnorm(20, 6, .8)
x3 = rnorm( 7, 4, .7)
x4 = rnorm(12, 7, 1)
x = c(x1,x2,x3,x4)
g = c(rep(1,10), rep(2,20), rep(3,7), rep(4,12))


Boxplots of the four small groups show some differences. The question is whether differences in sample means are great enough to reject the null hypothesis that group population means differ significantly.

boxplot(x~g, horizontal=T, col="skyblue2") In R, the procedure 'oneway.test' tests the null hypothesis that group population means are all equal against the alternative that there are differences among the four population means.

oneway.test(x~g)

One-way analysis of means
(not assuming equal variances)

data:  x and g
F = 24.824, num df = 3.000, denom df = 17.455, p-value = 1.597e-06


The very small P-value (nearly $$0)$$ indicates that the null hypothesis is rejected.

You could use ad hoc tests to explore which means are significantly different from which others. You might use Welch 2-sample t tests for this, insisting on significance at about the 1% level (depending on how many of the six possible pairs of groups you want to explore) to avoid 'false discovery' from repeated analyses of the same data.