Open in App
Not now

# Levene’s test

• Last Updated : 21 May, 2021

Levene’s test is used to assess the equality of variance between two different samples. For every case, it calculates the absolute difference between the value of that case and its cell mean and performs a one-way analysis of variance (ANOVA) on those differences

#### Assumptions

• The samples from the populations under consideration are independent.
• The populations under consideration are approximately normally distributed.

#### How to Perform Levene’s test

• The null hypothesis for Levene’s test is that the variance among groups is equal.

• The alternative hypothesis is that the variance among different groups is not equal (for at least one pair the variance is not equal to others).

• The test statistics for Levene’s test is:

• where,
• k: number of different groups to which the sampled cases belong.
• Ni: Number of elements in different groups.
• N: total number of cases in all groups

• where,
• Yij: the value of jth case and ith group.

[Tex]Z_{..} = \frac{1}{N_i}\sum_{i=1}^{K}\sum_{j=1}^{N_i}Z_{ij} \, where \, Z_{ij} \,is \, the\, mean \, of \, all. [/Tex]

• There are three types of Levene’s statistics available
• If a distribution has longer tailed distribution like the Cauchy distribution then we use trimmed mean.
• For skewed distribution, if the distribution is not clear we will use the median for test statistics.
• For the symmetric distribution and moderately tailed distribution, we use mean value for distribution.
• Decide the level of significance (alpha). Generally, we take it as 0.05.
• Find the critical value in the F-distribution table for the given level of significance, (N-k) and (k-1) parameters.
• If W > F∝, k-1, N-k, then we reject the null hypothesis.
• else, we do not reject the null hypothesis.

#### Example:

• Suppose there are 2 groups of students containing their scores in a maths test are below:
• Here, our null hypothesis is defined as:

• and the alternate hypothesis is

• And our level of significance is:

• Now, calculate the test statistics using above formula
• where, meanVar is ,

• and k-1 = Num of groups -1 =1
• N-k = 20-2 =18.
• By solving the test statistics using following parameters

[Tex]W = 0.54481[/Tex]

• Since, W < F0.05,1,19 , hence we do not reject the null hypothesis.

## Python3

 from scipy.stats import levene # define groups group_1 = [14, 34, 16, 43, 45, 36, 42, 43, 16, 27] group_2 = [34, 36, 44, 18, 42, 39, 16, 35, 15, 33]   # define alpha alpha =0.05 # now we pass the groups and center value from the following # ('trimmed mean', 'mean', 'median') w_stats, p_value =levene(group_1,group_2, center ='mean')   if p_value > alpha :   print("We do not reject the null hypothesis") else:   print("Reject the Null Hypothesis")

We do not reject the null hypothesis

My Personal Notes arrow_drop_up
Related Articles