Performs Bartlett's test of the null that the variances in each of the groups (samples) are the same.
bartlett_test(x, g, ...)# S3 method for default
bartlett_test(x, g, ...)
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").
a vector or factor object giving the group for the corresponding elements of x. Ignored if x is a list.
further arguments to be passed to or from methods.
A list with class "bartlett_htest"
containing the following
components:
Bartlett's K-squared test statistic.
the degrees of freedom of the approximate chi-squared distribution of the test statistic.
the p-value of the test.
a confidence interval for the mean appropriate to the specified alternative hypothesis.
the character string "Bartlett test of homogeneity of variances".
a character string giving the names of the data.
the sample variances across groups (samples).
the number of observations per group (sample)
In order to allow users to enjoy the functionality of bain with the familiar
stats-function bartlett.test
, we have had to make minor changes to the
function bartlett.test.default
. All rights to, and credit for, the
function bartlett.test.default
belong to the R Core Team, as indicated in the original license below.
We make no claims to copyright and incur no liability with regard to the
changes implemented in bartlett_test
.
This the original copyright notice by the R core team: File src/library/stats/R/bartlett_test.R Part of the R package, https://www.R-project.org
Copyright (C) 1995-2015 The R Core Team
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License is available at https://www.R-project.org/Licenses/
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
.
Bartlett, M. S. (1937). Properties of sufficiency and statistical tests. Proceedings of the Royal Society of London Series A 160, 268<U+2013>282. DOI: 10.1098/rspa.1937.0109.
# NOT RUN {
require(graphics)
plot(count ~ spray, data = InsectSprays)
bartlett_test(InsectSprays$count, InsectSprays$spray)
# }
Run the code above in your browser using DataLab