# Z-scores for different size groups

I want to know how I can calculate the Z-scores for groups with different sizes?

Let me try to explain: We have a city with 100.000 inhabitans. The city is divided in 10 neighborhoods, all with different size, say 1 neighborhood has 5000 inh., and another has 15.000 inh. etc. All the inhabitans can score a Yes or No as value => we translate this to 1 or 0

So we have a mean for the city as a whole (say 26% of the city scores a yes) and whe have scores per neighborhood (neighborhood 1 = 15%, neighborhood 2 = 31% etc)

Now I want to calculate at the Z-scores for each neighborhood referenced to the city mean (26%), how do I calculate this and how about the proportions of the neighborhoods and how do I calculate the standard deviation (I need SD for Z-scores)

• What would be the purpose of computing these Z-scores? What do you hope they will tell you? – whuber May 24 '19 at 14:06
• I want to see how much all the neighborhoods are different from the mean in Z-scores, standardized – MacMax May 24 '19 at 19:58
• Comparing Z-scores lacks any scientific meaning--it's not an objective in its own right. It sounds like you want to compare the mean values among neighborhoods. The standard method, which is easy and should work well, is ANOVA. – whuber May 24 '19 at 20:28

Comment:

Suppose the city has population 100,000, with 26% Yes's; that's $$X = 2600$$ Yes's.

Suppose neighborhood A has population 5000 with 15% Yes's; that's $$Y = 750$$ Yes's.

It would make sense to compare neighborhood A with the rest of the city, which has population 95,000 and $$26,000-750 = 25,250$$ Yes's.

That can be done with a 'test of two proportions'. Minitab output follows, where Sample 1 is from neighborhood A (15% Yes's) and Sample 2 is for the rest of the city (26.58% Yes's).

Test and CI for Two Proportions

Sample      X      N  Sample p
1         750   5000  0.150000
2       25250  95000  0.265789

Difference = p (1) - p (2)
Estimate for difference:  -0.115789
95% CI for difference:  (-0.126078, -0.105501)
Test for difference = 0 (vs ≠ 0):
Z = -22.06  P-Value = 0.000


It is usually bad practice to compare part of a population with the population as a whole: that way some individuals are double-counted. That is why I compared neighborhood A with the rest of the city.

With numbers as large as these, even some 'fairly small' differences in percentages will turn out to be significant (as happened in this example). That is, the null hypothesis that the two percentages are equal, will be rejected at the 5% level (P-value less than 5%).

You might also want to compare two different neighborhoods using such a test. Not all comparisons will be significant: If neighborhood B has population 10,000 with 16% Yes's, that's not significantly different from neighborhood A.

 Test and CI for Two Proportions

Sample     X      N  Sample p
1        750   5000  0.150000     # Nbd A
2       1600  10000  0.160000     # Nbd B

Difference = p (1) - p (2)
Estimate for difference:  -0.01
95% CI for difference:  (-0.0222306, 0.00223055)
Test for difference = 0 (vs ≠ 0):
Z = -1.60  P-Value = 0.109


Another idea: Maybe you want to make a list of neighborhoods and their observed percentages of Yes answers, along with a confidence interval showing what the true percentages might be.

For neighborhood A, a 95% confidence interval would be $$.15 \pm 1.96\sqrt{\frac{(.15)(1-.15)}{5000}},$$ That amounts to a percentage of $$15 \pm 0.1.$$

For neighborhood B, its a percentage of $$16 \pm 0.07.$$

In a comment you say you want to see if "the neighborhoods are different in z scores" but if you want to see if the neighborhoods are different, z scores are not the way to go. In his answer, BruceET made a few good suggestions. I have one more: You can do logistic regression with "neighborhood" as an independent variable and whatever it is you are working with as a dependent variable. This lets you compare all the neighborhoods at the same time.

The problem with comparing the mean of each neighbourhood with the overall mean is that the observations won't be independent.

With this I mean that, for a comparison between neighbourhood A and the overall mean, the results from neighbourhood A are influencing the overall mean (which is not supposed to happen when doing population comparison). For that reason, as pointed out by @whuber and @BruceET, an ANOVA test is preferred.

The idea behind ANOVA is to fit a very simple type of regression model where the variables are "belonging to neighbourhood A", "belonging to neighbourhood B" and so on... Then check how much of an effect those artificial variables have