Rev 27453 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{bartlett.test}\alias{bartlett.test}\alias{bartlett.test.default}\alias{bartlett.test.formula}\title{Bartlett Test for Homogeneity of Variances}\description{Performs Bartlett's test of the null that the variances in each of thegroups (samples) are the same.}\usage{bartlett.test(x, \dots)\method{bartlett.test}{default}(x, g, \dots)\method{bartlett.test}{formula}(formula, data, subset, na.action, \dots)}\arguments{\item{x}{a numeric vector of data values, or a list of numeric datavectors representing the respective samples, or fitted linear modelobjects (inheriting from class \code{"lm"}).}\item{g}{a vector or factor object giving the group for thecorresponding elements of \code{x}.Ignored if \code{x} is a list.}\item{formula}{a formula of the form \code{lhs ~ rhs} where \code{lhs}gives the data values and \code{rhs} the corresponding groups.}\item{data}{an optional data frame containing the variables in themodel formula.}\item{subset}{an optional vector specifying a subset of observationsto be used.}\item{na.action}{a function which indicates what should happen whenthe data contain \code{NA}s. Defaults to\code{getOption("na.action")}.}\item{\dots}{further arguments to be passed to or from methods.}}\details{If \code{x} is a list, its elements are taken as the samples or fittedlinear models to be compared for homogeneity of variances. In thiscase, the elements must either all be numeric data vectors or fittedlinear model objects, \code{g} is ignored, and one can simply use\code{bartlett.test(x)} to perform the test. If the samples are notyet contained in a list, use \code{bartlett.test(list(x, ...))}.Otherwise, \code{x} must be a numeric data vector, and \code{g} mustbe a vector or factor object of the same length as \code{x} giving thegroup for the corresponding elements of \code{x}.}\value{A list of class \code{"htest"} containing the following components:\item{statistic}{Bartlett's K-squared test statistic.}\item{parameter}{the degrees of freedom of the approximate chi-squareddistribution of the test statistic.}\item{p.value}{the p-value of the test.}\item{method}{the character string\code{"Bartlett test for homogeneity of variances"}.}\item{data.name}{a character string giving the names of the data.}}\seealso{\code{\link{var.test}} for the special case of comparing variances intwo samples from normal distributions;\code{\link{fligner.test}} for a rank-based (nonparametric)\eqn{k}-sample test for homogeneity of variances;\code{\link{ansari.test}} and \code{\link{mood.test}} for two rankbased two-sample tests for difference in scale.}\references{Bartlett, M. S. (1937).Properties of sufficiency and statistical tests.\emph{Proceedings of the Royal Statistical Society Series A}\bold{160}, 268--282.}\examples{% FIXME: could use something more interesting heredata(InsectSprays)plot(count ~ spray, data = InsectSprays)bartlett.test(InsectSprays$count, InsectSprays$spray)bartlett.test(count ~ spray, data = InsectSprays)}\keyword{htest}