[R] desperate!
KAREN KOTSCHY
karen at gecko.biol.wits.ac.za
Thu Nov 25 14:14:53 CET 1999
Dear R community
I sent a message out a while ago asking for help with multiple
comparison tests for ANOVA's, but haven't had any response yet.
I'm sending a final desperate plea. If I can't get this done in R I'm
going to have to redo a whole lot of stuff in a commercial package,
which I'm REALLY not keen to do!
My problem is how to implement these tests in R. Below is some
code posted by Thomas Lumley which I might be able to use
(sorry, I forgot to include the code in my last email). But I'm battling
to follow what this code exactly does (especially the last bit). How
would I link it to the ANOVA results? What sort of output would
these functions give me - adjusted p values? How would I then
interpret these?
I'd really appreciate any help!!!
-----------------
Code for Bonferroni, Holm and Hochberg post hoc tests:
p.adjust.holm <- function(p, n=length(p)) {
##n <- length(p)
r <- rank(p)
index <- order(p)
qi <- p*(n+1-r)
for (i in 2:length(p)) {
qi[index[i]] <- max(qi[index[i+1]])
}
list(adjp=pmin(qi, 1), p=p, method="Holm")
}
p.adjust.hochberg <- function(p) {
n <- length(p)
r <- rank(p)
index <- order(p)
qi <- p*(n+1-r)
for (i in (n-1):1) {
qi[index[i]] <- min(qi[index[i]], qi[index[i+1]])
}
list(adjp=qi, p=p, method="Hochberg")
}
p.adjust.bonferroni <- function(p, n=length(p)) {
list(adjp=pmin(p*n, 1), p=p, method="Bonferroni")
}
------------------
p.adjust <- function(p, method=c("hochberg", "holm",
"bonferroni"),...) {
how <- pmatch(method[1], c("hochberg", "holm", "bonferroni"))
if(is.na(how) stop(paste("Don't know method"))
m <- match.call()
m[[1]] <- as.name(paste("p.adjust", c("hochberg", "holm",
"bonferroni")[how], sep="."))
m$method <- NULL
eval(m, sys.parent())
}
---------------------
Karen Kotschy
Centre for Water in the Environment
Department of Animal, Plant and Environmental sciences
University of the Witwatersrand
Johannesburg
South Africa
Tel : +2911 716-2218
Postal address:
P/Bag 3
P.O Wits
2050
South Africa
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list