leveneTest
Levene's Test
Computes Levene's test for homogeneity of variance across groups.
- Keywords
- htest
Usage
leveneTest(y, ...)
# S3 method for formula
leveneTest(y, data, ...)
# S3 method for lm
leveneTest(y, ...)
# S3 method for default
leveneTest(y, group, center=median, ...)
Arguments
- y
response variable for the default method, or a
lm
orformula
object. Ify
is a linear-model object or a formula, the variables on the right-hand-side of the model must all be factors and must be completely crossed.- group
factor defining groups.
- center
The name of a function to compute the center of each group;
mean
gives the original Levene's test; the default,median
, provides a more robust test.- data
a data frame for evaluating the
formula
.- ...
arguments to be passed down, e.g.,
data
for theformula
andlm
methods; can also be used to pass arguments to the function given bycenter
(e.g.,center=mean
andtrim=0.1
specify the 10% trimmed mean).
Value
returns an object meant to be printed showing the results of the test.
Note
adapted from a response posted by Brian Ripley to the r-help email list.
References
Fox, J. (2016) Applied Regression Analysis and Generalized Linear Models, Third Edition. Sage.
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
Examples
# NOT RUN {
with(Moore, leveneTest(conformity, fcategory))
with(Moore, leveneTest(conformity, interaction(fcategory, partner.status)))
leveneTest(conformity ~ fcategory*partner.status, data=Moore)
leveneTest(lm(conformity ~ fcategory*partner.status, data=Moore))
leveneTest(conformity ~ fcategory*partner.status, data=Moore, center=mean)
leveneTest(conformity ~ fcategory*partner.status, data=Moore, center=mean, trim=0.1)
# }