bartlett.test
Bartlett Test of Homogeneity of Variances

Description

Performs the Bartlett test of homogeneity of variances.

Usage

bartlett.test(x, ...)
## Default S3 method:
bartlett.test(x, g, ...) 
## S3 method for class 'formula':
bartlett.test(formula, data, subset, na.action, ...) 

Arguments

x a numeric vector or a list with at least 2 numeric or linear model elements representing the variances.
g a vector or factor object giving the group of the corresponding elements of x. This argument is not used if x is a list.
formula a formula specifying the variables to use in the computations. To compute and perform the Bartlett test of homogeneity of variances of a and b, the formula follows the pattern a ~ b .
data a data frame or matrix containing the objects named in formula. By default, this argument reads in values from the environment.
subset a vector specifying a subset from the data frame (data) to use in formula.
na.action a function that handles missing values. See na.action for details.
... other arguments that are appropriate for the particular call.

Details

bartlett.test is a generic function to perform the Bartlett test of homogeneity of variances. The variances can be given in the format of a list of data values, a list of linear model objects, a vector of data values and a vector or factor of group data values, or a formula with variables.
The Bartlett's K-squared test statistic is calculated as the following formula.
statistic = (sum(n) * log(sum(n*v)/sum(n)) - sum(n * log(v)))/(1 + (sum(1/n) - 1/sum(n))/(3 * (k - 1)))
where the following is given.
The Bartlett K-squared test statistic parameter (degrees of freedom) is simply calculated as the number of groups, minus one (that is k-1).
The p-value is calculated as pchisq(statistic, parameter, lower.tail = FALSE).
Value
returns a list object of class "htest" containing the following components:
statistic Bartlett's K-squared test statistic.
parameter the degrees of freedom of chi-squared distribution of the test statistic.
p.value the p-value of the Bartlett's K-squared test.
data.name a character string containing the actual data names.
method a string containing the name of the test. For example, "Bartlett test of homogeneity of variances".
References
Bartlett, M. S. 1937. Properties of sufficiency and statistical tests. Proceedings of the Royal Society of London Series A. Volume 160. 268-282.
See Also
var.test, cor.test, chisq.test, na.action
Examples

bartlett.test(breaks~wool, data = warpbreaks) bartlett.test(warpbreaks$breaks, warpbreaks$tension)

# Examples for list of data bartlett.test(list(X1 = runif(5), X2 = runif(6), X3 = runif(4))) bartlett.test(list(X1 = 1:5, X2 = (6:1)^2, X3 = sqrt(1:4)))

# Examples for linear models. x <- runif(10) y <- 5 + rnorm(10) z <- sqrt(x + y ) * 2 + runif(10) lm1 <- lm(y~x) lm2 <- lm(z~y+x) lm3 <- lm(z~y) bartlett.test(list(lm1, lm2, lm3))

Package stats version 6.1.1-7
Package Index