bartlettTest
Performs Bartlett's test for equality of variances across two or more groups.
The null hypothesis is that all groups have equal variances (homoscedasticity). The test compares the pooled variance to the individual group variances using a log-likelihood ratio with a correction factor for small samples. The test statistic follows a chi-squared distribution with k - 1 degrees of freedom. Assumes that the data in each group are normally distributed. For non-normal data, consider using leveneTest or flignerKilleenTest instead, which are more robust to departures from normality.
Example:
val g1 = doubleArrayOf(10.0, 11.0, 12.0, 9.0, 10.0)
val g2 = doubleArrayOf(5.0, 15.0, 10.0, 20.0, 0.0)
val result = bartlettTest(g1, g2)
result.statistic // chi-squared test statistic
result.pValue // p-value from chi-squared distribution
result.degreesOfFreedom // k - 1
result.additionalInfo["pooledVariance"] // pooled sample varianceReturn
a TestResult containing the test statistic, p-value, degrees of freedom (k - 1), and additional info with "pooledVariance".
Parameters
two or more groups of observations, each with at least 2 elements.