# Homogeneity of variance is violated for z-scores but not for raw data?

Is this a normal thing to happen or have I done something wrong in SPSS? I am using a Levene's test.

• This seemed trivial, but turned out to be quite an interesting question for me. – Fato39 Apr 15 '15 at 13:54
• I think you made an error in your question, however. If anything the relationship should be reversed. The Levene's W should be higher for raw data and p smaller. – Fato39 Apr 15 '15 at 14:55

This depends on how you normalized your data: calculated z-scores for the whole set of data OR used group-by-group standardization.

If you transformed your data into z-scores using the mean and the standard deviation of the whole set, then the result should not be different. If, however, you standardized your data for each of the groups separately (i.e. using group averages and standard deviations), then the Levene's W statistic is diminished.

The first case is very simple to check, using R's in-built set of data Moore. Merely try out the following two commands, where the first one performs the Levene's test (from carpackage) on the untransformed data and the second one on the z-scores.

leveneTest(Moore$conformity,Moore$fcategory)
leveneTest(scale(Moore$conformity)[,1],Moore$fcategory)


The result is the same in both cases, namely:

    Levene's Test for Homogeneity of Variance (center = median)
Df F value Pr(>F)
group  2   0.046 0.9551
42


The option center is irrelevant for the purpose of this illustration.

Showing why, analytically, is not straightforward. Some intuition can be gained, however, by studying the equation for Levene's W (taken from the Wikipedia's article with the test's name):

$$W = \frac{(N-k)}{(k-1)} \frac{\sum_{i=1}^k N_i (Z_{i\cdot}-Z_{\cdot\cdot})^2} {\sum_{i=1}^k \sum_{j=1}^{N_i} (Z_{ij}-Z_{i\cdot})^2}$$

with $Z_{ij}=|Y_{ij} - \bar{Y}_{i\cdot}|$ and $\bar{Y}_{i\cdot}$ the mean of i-th group, $Z_{\cdot\cdot} = \frac{1}{N} \sum_{i=1}^{k} \sum_{j=1}^{N_i}Z_{ij}$ the mean of all $Z_{ij}$, and $Z_{i\cdot} = \frac{1}{N_i} \sum_{j=1}^{N_i} Z_{ij}$ again the group mean.

While the denominator of the second fraction does not differ no matter how you standardize the data (which is not immediately apparent at all), the numerator is smaller when you standardize each group separately. This is because $Z_{i\cdot}$ and $Z_{\cdot\cdot}$ are closer together in this case.

An analytic derivation would be much more convincing here, but for illustration purposes your own example and the one I mentioned above will have to suffice.

## Edit

To see an example, where the variances are non-homogeneous for raw data and how this changes with z-scores, you can use the mtcars dataset:

leveneTest(mtcars$mpg,mtcars$am,center=mean)
Levene's Test for Homogeneity of Variance (center = mean)
Df F value  Pr(>F)
group  1   5.921 0.02113 *
30
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


versus

attach(mtcars)
df<-mtcars[order(am),]
df$mpgZ<-rbind(scale(mtcars$mpg[which(mtcars$am==0)]),scale(mtcars$mpg[which(mtcars$am==1)])) #scale the data separately based on transmission type (am) leveneTest(df$mpgZ[,1],df\$am,center=mean)
Levene's Test for Homogeneity of Variance (center = mean)
Df F value Pr(>F)
group  1  0.0818 0.7769
30

• Of course, when you think about this in the broader context of homoscedasticity testing, an intuitive explanation might be grasped easier. See my other answer. – Fato39 Apr 15 '15 at 14:32
• I agree with your answer, but the OP is asking about an example where the ‘homogeneity of variance is violated for z-scores but not for raw data’, which is exactly the opposite case (and which sounds like a very strange (impossible?) case, cf. your answer). – Karl Ove Hufthammer Apr 15 '15 at 16:24
• @KarlOveHufthammer Thank you for the comment. I would agree the proposed scenario is very unlikely, so I assumed the OP must have made a mistake when asking the question. I would be happy, however, if OP could elaborate on the matter, i.e. give specific W and p values. – Fato39 Apr 15 '15 at 19:51

For a more intuitive explanation, one should think about what testing for homogeneity of variance really means. Roughly put, it serves to determine whether dispersion of data is the same for all groups. A naive approach would be to take ratios of variances and see if they are all (approximately) equal to one.

When standardizing the data for each of the group separately, by definition, the standard deviation of each is made to equal 1. Therefore, all variances are equal and the Levene's test gives a non-significant result.

When standardizing the whole set of data, the variances are all scaled by the same factor. Their relationship remains the same as before standardization, i.e. the outcome of any test of homogeneity of variance remains the same.