bartlett.test(x, ...) ## Default S3 method: bartlett.test(x, g, ...) ## S3 method for class 'formula': bartlett.test(formula, data, subset, na.action, ...)
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. |
statistic = (sum(n) * log(sum(n*v)/sum(n)) - sum(n * log(v)))/(1 + (sum(1/n) - 1/sum(n))/(3 * (k - 1))) | ||
If x is a list of linear model objects, each element of n is the value of the "df.resid" component of each linear model object.
If x is a list of linear model objects, each element of v is the sum of the square of the value of the "residuals" component of each linear model object.
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". |
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))