[R] levene.test

John Fox jfox at mcmaster.ca
Wed Jul 14 15:08:14 CEST 2010


Dear Marta,

As it says in ?levene.test, "The version of Levene's test implemented here
is based on absolute deviations from the group medians. Other, less robust,
versions, not implemented, are based on absolute deviations from group means
or trimmed means." What does SPSS do? (Possibly it uses means rather than
medians.) If you want a Levene test based on means or any other measure of
centre, that's implemented in the development version of the car package on
R-Forge, where the function is renamed leveneTest. 

To see exactly what levene.test does, you can simply look at the code, which
is in the default method for the levene.test function; the computation is
very simple:

> car:::levene.test.default
function (y, group, ...) 
{
    if (!is.numeric(y)) 
        stop(deparse(substitute(y)), " is not a numeric variable")
    if (!is.factor(group)) {
        warning(deparse(substitute(group)), " coerced to factor.")
        group <- as.factor(group)
    }
    meds <- tapply(y, group, median, na.rm = TRUE)
    resp <- abs(y - meds[group])
    table <- anova(lm(resp ~ group))[, c(1, 4, 5)]
    rownames(table)[2] <- " "
    attr(table, "heading") <- "Levene's Test for Homogeneity of Variance"
    table
}

Regards,
 John

--------------------------------
John Fox
Senator William McMaster 
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of martanair
> Sent: July-14-10 8:48 AM
> To: r-help at r-project.org
> Subject: Re: [R] levene.test
> 
> 
> the value of the F-test is uncorrect.
> If I calculate the Levene's Test for Homogeneity of Variance with SPSS I
get
> F = 5.128 Pr (> F) = 0.033
> Why?
> what is the exact formula which R calculate Levene's test for two groups?
> Thanks
> marta
> --
> View this message in context: http://r.789695.n4.nabble.com/levene-test-
> tp2288632p2288684.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list