bartlett.test: Bartlett Test of Homogeneity of Variances

Description Usage Arguments Details Value References See Also Examples

Description

Performs Bartlett's test of the null that the variances in each of the groups (samples) are the same.

Usage

 1 2 3 4 5 6 7 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 of data values, or a list of numeric data vectors representing the respective samples, or fitted linear model objects (inheriting from class "lm"). g a vector or factor object giving the group for the corresponding elements of x. Ignored if x is a list. formula a formula of the form lhs ~ rhs where lhs gives the data values and rhs the corresponding groups. data an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula). subset an optional vector specifying a subset of observations to be used. na.action a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action"). ... further arguments to be passed to or from methods.

Details

If x is a list, its elements are taken as the samples or fitted linear models to be compared for homogeneity of variances. In this case, the elements must either all be numeric data vectors or fitted linear model objects, g is ignored, and one can simply use bartlett.test(x) to perform the test. If the samples are not yet contained in a list, use bartlett.test(list(x, ...)).

Otherwise, x must be a numeric data vector, and g must be a vector or factor object of the same length as x giving the group for the corresponding elements of x.

Value

A list of class "htest" containing the following components:

 statistic Bartlett's K-squared test statistic. parameter the degrees of freedom of the approximate chi-squared distribution of the test statistic. p.value the p-value of the test. method the character string "Bartlett test of homogeneity of variances". data.name a character string giving the names of the data.

References

Bartlett, M. S. (1937). Properties of sufficiency and statistical tests. Proceedings of the Royal Society of London Series A 160, 268–282. \Sexpr[results=rd,stage=build]{tools:::Rd_expr_doi("10.1098/rspa.1937.0109")}.