[R] Help in using multcomp.
Chuck Cleland
ccleland at optonline.net
Fri Feb 9 18:23:58 CET 2007
A Ezhil wrote:
> Hi All,
>
> I am trying use 'multcomp' for multiple comparisons
> after my ANOVA analysis. I have used the following
> code to do ANOVA:
>
> dat <- matrix(rnorm(45), nrow=5, ncol=9)
> f <- gl(3,3,9, label=c("C", "Tl", "T2"))
>
> aof <- function(x) {
> m <- data.frame(f, x);
> aov(x ~ f, m)
> }
> amod <- apply(dat,1,aof)
>
> Now, how can I use 'glht' for the above amod. I know
> that I cannot use simply
>
> glht(amod, linfct = mcp(f = "Dunnett")).
Since amod is a list of models rather than one model, do you want
something like this?
lapply(amod, function(x){summary(glht(x, linfct = mcp(f = "Dunnett")))})
> Also, if I want to use Dunnett for comparing C vs (T1
> and T2), how can I specify this in the glht function.
How about doing it with user-defined contrasts?
contr <- rbind("C - T1 " = c(-1, 1, 0),
"C - T2 " = c(-1, 0, 1),
"C - All T" = c(-1,.5,.5))
lapply(amod, function(x){summary(glht(x, linfct = mcp(f = contr)))})
> Thanks in advance.
> Regards,
> Ezhil
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list