# Levene's test

In statistics, Levene's test[1] is an inferential statistic used to assess the equality of variances for a variable calculated for two or more groups. Some common statistical procedures assume that variances of the populations from which different samples are drawn are equal. Levene's test assesses this assumption. It tests the null hypothesis that the population variances are equal (called homogeneity of variance or homoscedasticity). If the resulting P-value of Levene's test is less than some significance level (typically 0.05), the obtained differences in sample variances are unlikely to have occurred based on random sampling from a population with equal variances. Thus, the null hypothesis of equal variances is rejected and it is concluded that there is a difference between the variances in the population.

Some of the procedures typically assuming homoscedasticity, for which one can use Levene's tests, include analysis of variance and t-tests.

Levene's test is often used before a comparison of means. When Levene's test shows significance, one should switch to generalized tests, free from homoscedasticity assumptions.

Levene's test may also be used as a main test for answering a stand-alone question of whether two sub-samples in a given population have equal or different variances.

## Definition

The test statistic, W, is defined as follows:

$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},$

where

• $W$ is the result of the test,
• $k$ is the number of different groups to which the sampled cases belong,
• $N$ is the total number of cases in all groups,
• $N_i$ is the number of cases in the $i$th group,
• $Y_{ij}$ is the value of the measured variable for the$j$th case from the $i$th group,
• $Z_{ij} = \left\{\begin{matrix} |Y_{ij} - \bar{Y}_{i\cdot}|, & \bar{Y}_{i\cdot} \mbox{ is a mean of i-th group } \\ |Y_{ij} - \tilde{Y}_{i\cdot}|, & \tilde{Y}_{i\cdot} \mbox{ is a median of i-th group } \end{matrix}\right.$

(Both definitions are in use though the second one is, strictly speaking, the Brown–Forsythe test – see below for comparison)

• $Z_{\cdot\cdot} = \frac{1}{N} \sum_{i=1}^{k} \sum_{j=1}^{N_i} Z_{ij}$ is the mean of all $Z_{ij}$,
• $Z_{i\cdot} = \frac{1}{N_i} \sum_{j=1}^{N_i} Z_{ij}$ is the mean of the $Z_{ij}$ for group $i$.

The significance of $W$ is tested against $F(\alpha,k-1,N-k)$ where $F$ is a quantile of the F-test distribution, with $k-1$ and $N-k$ its degrees of freedom, and $\alpha$ is the chosen level of significance (usually 0.05 or 0.01).

## Comparison with the Brown–Forsythe test

The Brown–Forsythe test uses the median instead of the mean. Although the optimal choice depends on the underlying distribution, the definition based on the median is recommended as the choice that provides good robustness against many types of non-normal data while retaining good statistical power. If one has knowledge of the underlying distribution of the data, this may indicate using one of the other choices. Brown and Forsythe performed Monte Carlo studies that indicated that using the trimmed mean performed best when the underlying data followed a Cauchy distribution (a heavy-tailed distribution) and the median performed best when the underlying data followed a Chi-squared distribution with four degrees of freedom (a heavily skewed distribution). Using the mean provided the best power for symmetric, moderate-tailed, distributions.