[R] Levene test of homogeneity of variance

John Fox jfox at mcmaster.ca
Wed Aug 13 17:15:43 CEST 2003


Dear Maurice,

Brian Ripley once posted a function for Levene's test to the R-help list. I 
incorporated a slightly modified version in the Rcmdr package. Since the 
function is very simple, I'll just list it here (it doesn't make sense to 
use the Rcmdr package just for this function):

levene.test <- function(y, group) {
     meds <- tapply(y, group, median, na.rm=TRUE)
     resp <- abs(y - meds[group])
     table <- anova(lm(resp ~ group))
     rownames(table)[2] <- " "
     cat("Levene's Test for Homogeneity of Variance\n\n")
     table[,c(1,4,5)]
     }

By the way, "group" is a factor.

John

At 10:39 AM 8/13/2003 -0400, Haynes, Maurice (NIH/NICHD) wrote:
>Has the Levene test of homogeneity of variance been implemented in any
>library in R?
>
>Thanks,
>
>Maurice Haynes

-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox




More information about the R-help mailing list