You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Useful to quickly calculate multiple Levene tests:
# x is a matrix of values (including NAs) from two or more groups# g contains the group for each columnleveneTest<-function(x, g, centers=c("median", "mean")) {
centers<- match.arg(centers)
dname<- paste(deparse(substitute(x)), "and", deparse(substitute(g)))
# Convert groups to factorsg<-factor(g)
if (centers=="median") {
res<- calculateRowMediansByGroups(x, g)
} elseif (centers=="mean") {
res<- calculateRowMeansByGroups(x, g)
}
spread<- abs(t(x) -res[rep(g, nrow(x))])
fit<- lm.fit(model.matrix(~g), spread)
# Modified `stats:::anova.lm()` to accept `stats::lm.fit()` with multiple results# All the attributes needed to run `stats::anova.lm()` are available in `fit`var<- modANOVA(fit)
# Prepare resultsstatistic<-var$`F value`pval<-var$`Pr(>F)`centers<- deparse(substitute(centers))
rval<-list(statistic=c("W"=statistic), p.value=pval, data.name=dname,
method=paste0("Levene's test (using the ", centers, ")"))
class(rval) <-"htest"return(rval)
}
The text was updated successfully, but these errors were encountered:
nuno-agostinho
changed the title
Quick ANOVA using a matrix as input
Quick multiple ANOVA testing using a matrix as input
Aug 6, 2020
Useful to quickly calculate multiple Levene tests:
The text was updated successfully, but these errors were encountered: