In relation to another question, Ben Bolker writes that

  • if you have all-categorical predictors, you can test for heteroscedasticity (and other issues such as non-Normality) by dividing the data into unique combinations of categories (i.e., in the t-test, compare the variability in each group).
  • if you have continuous predictors, then the only way to test the conditional distribution is to fit the model first, then evaluate the distribution of the residuals. Furthermore, even after you have the residuals, there generally aren't discrete groups in the data to which you could apply Levene's test.

In ANCOVA we do have a continuous predictor (the covariate). However, some statistical programs still report Levene's test in relation to ANCOVA. Here's an example a textbook provides from SPSS, in which Dose is a categorical predictor and Partner_Libido is a continuous covariate.


According to the author, this table

shows the results of Levene's test when partner's libido is included in the model as a covariate. Levene's test is significant, indicating that the group variances are not equal (and hence the assumption of homogeneity of variance has likely been violated).

Is ANCOVA a case in contradiction to Ben's general point that "even after you have the residuals, there generally aren't discrete groups in the data to which you could apply Levene's test"? Why/why not?

I realise that there's a school of thought that Levene's test is not really ever worth doing, even in relation to ANOVA/t-tests. But my question is whether Levene's test makes less sense in relation to ANCOVA than ANOVA/t-tests.


It's not completely clear to me from that link whether SPSS is applying the Levene test to residuals or to the original observations within each group (I assume it's using residuals, but its quite possible I missed something). In any case Ben is correct, even if you do it with residuals the test doesn't really do what is needed.

In my examples, y is the DV, x is the group variable and z is the covariate.

  1. There's more than one variable in the ANCOVA; you can compare the residual variance in the two groups but equal population variances in the two groups aggregated across the covariate is not sufficient to satisfy the assumptions on which the tests need to be based.

    Keeping in mind that the variance assumption on which the usual calculations are based is that all observations have the same population variance, consider an example where the variance is increasing with increasing values of the covariate:

    plot of a two group ANCOVA where the spread increases as the covariate increases

    As we see, the regression homoskedasticity assumption on which the test of coefficients are based is not satisfied but the population variance within each group is constant -- even if you look at residuals rather than original observations.

    Hopefully it's sufficient to see that in a situation like this the assumptions are not satisfied even though Levene would suggest that there's no problem (that is, a non-rejection is not really a consolation).

  2. If Levene's test is being carried out on the original observations instead of the residuals, we would see another problem:

    plot of data for a two group ANCOVA where the within-group variance where the covariate has a wider range in one of the groups

    Here the within-group spreads on the original data are plainly different even though the assumptions required for the test are actually satisfied.

    (Again, I assume SPSS isn't doing this, but I couldn't figure out for sure whether that was the case from your link.)

| cite | improve this answer | |
  • $\begingroup$ I had to check references on Levene's Test to understand this, because my concept of this test is at once simpler and broader than what seems to be usually described: it is an ANOVA on the absolute residuals; or, more broadly, a regression of the absolute residuals against the original explanatory variables. If that regression is significant, you have detected some variation in the size of the residual. Is this perhaps an unusual understanding of the test? $\endgroup$ – whuber May 6 '19 at 14:53
  • $\begingroup$ FWIW, here's an example that succeeds in detecting heteroscedasticity (even though the original regression isn't significant!). n <- 20; set.seed(17); X <- data.frame(x=rep(0:1, n), z=rep(1:n, each=2)); X$y <- with(X, x + (1/n)*z + rnorm(2*n, 0, (z/n))); fit <- lm(y ~ x + z, X) ; X$r <- abs(residuals(fit)); summary(lm(r ~ x + z, X)) $\endgroup$ – whuber May 6 '19 at 14:54
  • 1
    $\begingroup$ Levene's test can detect heteroskedasticity, and used in the way you're suggesting should work just fine on both my examples, but that's not the way I interpreted the comparison being done at the OP's link; the difficulty is being able to tell exactly what was being done (it's not explicit and searching for more information turned up a number of hits that were all just as vague about it); in the cases where I could glean anything about what was going on, I got the distinct impression the covariate was used to obtain residuals but only the grouping variable was used for Levene's test in SPSS. $\endgroup$ – Glen_b May 6 '19 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.