library(ggplot2)
library(MASS)
library(mvtnorm)

Bartlett’s Test

Bartlett’s test is used to examine if a positive, real number of samples from a population has equal variances, also known as a “homogeniety of variances”. It’s defined as:

\(H_0: \sigma_0^2 = \sigma_1^2 =...= \sigma_k^2\)

\(H_A: \sigma_i^2 \neq \sigma_j^2\)

\(T = \frac{(N-k)ln(s_p^2) - \sum^k_{i=1}(N_i - 1)ln(s^2_i)}{1 + \frac{1}{3(k-1)}*(\sum(\frac{1}{N_i - 1})) - \frac{1}{N-k}}\)

where…

An Example

data <- Orange
head(data, 3)
##   Tree age circumference
## 1    1 118            30
## 2    1 484            58
## 3    1 664            87
bartlett.test(circumference ~ Tree, data = data)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  circumference by Tree
## Bartlett's K-squared = 2.4607, df = 4, p-value = 0.6517
margin = 0.6517 - 0.05
margin
## [1] 0.6017