Statistics: levene_test

### Function Reference: `levene_test`

statistics: h = levene_test (x)
statistics: h = levene_test (x, group)
statistics: h = levene_test (x, alpha)
statistics: h = levene_test (x, testtype)
statistics: h = levene_test (x, group, alpha)
statistics: h = levene_test (x, group, testtype)
statistics: h = levene_test (x, group, alpha, testtype)
statistics: [h, pval] = levene_test (…)
statistics: [h, pval, W] = levene_test (…)
statistics: [h, pval, W, df] = levene_test (…)

Perform a Levene’s test for the homogeneity of variances.

Under the null hypothesis of equal variances, the test statistic W approximately follows an F distribution with df degrees of freedom being a vector ([k-1, N-k]).

The p-value (1 minus the CDF of this distribution at W) is returned in pval. h = 1 if the null hypothesis is rejected at the significance level of alpha. Otherwise h = 0.

Input Arguments:

- x contains the data and it can either be a vector or matrix. If x is a matrix, then each column is treated as a separate group. If x is a vector, then the group argument is mandatory. NaN values are omitted.
- group contains the names for each group. If x is a vector, then group must be a vector of the same length, or a string array or cell array of strings with one row for each element of x. x values corresponding to the same value of group are placed in the same group. If x is a matrix, then group can either be a cell array of strings of a character array, with one row per column of x in the same way it is used in `anova1` function. If x is a matrix, then group can be omitted either by entering an empty array ([]) or by parsing only alpha as a second argument (if required to change its default value).
- alpha is the statistical significance value at which the null hypothesis is rejected. Its default value is 0.05 and it can be parsed either as a second argument (when group is omitted) or as a third argument.
- testtype is a string determining the type of Levene’s test. By default it is set to "absolute", but the user can also parse "quadratic" in order to perform Levene’s Quadratic test for equal variances or "median" in order to to perform the Brown-Forsythe’s test. These options determine how the Z_ij values are computed. If an invalid name is parsed for testtype, then the Levene’s Absolute test is performed.

See also: bartlett_test, vartest2, vartestn

Source Code: levene_test