Dear Richard and Jinsong,

Others output with library agricolae. See manual.

##
library(agricolae)
comp1 <- LSD.test(x.aov,"a", group=FALSE)
comp2 <- LSD.test(x.aov,"b", group=TRUE)
# interaction ab
# Tukey's test
comp3 <- HSD.test(xi.aov,"ab")
# graphics
par(mfrow=c(2,2))
bar.err(comp1,ylim=c(0,100), col="yellow")
bar.group(comp2,ylim=c(0,100),density=4,col="blue")
bar.group(comp3,ylim=c(0,100), col="brown",las=2)
bar.err(comp3,ylim=c(0,100),col=0,las=2)

Regards,
Felipe de Mendiburu
Statistician

-----Original Message-----
From: r-help-bounces@r-project.org on behalf of Richard M. Heiberger
Sent: Wed 4/4/2012 9:49 PM
To: Jinsong Zhao
Cc: r-help@R-project.org
Subject: Re: [R] Fisher's LSD multiple comparisons in a two-way ANOVA
 
Here is your example.  The table you displayed in gigawiz ignored the
two-way factor structure
and interpreted the data as a single factor with 6 levels.  I created the
interaction of
a and b to get that behavior.


## your example, with data stored in a data.frame
tmp <- data.frame(x=c(76, 84, 78, 80, 82, 70, 62, 72,
                    71, 69, 72, 74, 66, 74, 68, 66,
                    69, 72, 72, 78, 74, 71, 73, 67,
                    86, 67, 72, 85, 87, 74, 83, 86,
                    66, 68, 70, 76, 78, 76, 69, 74,
                    72, 72, 76, 69, 69, 82, 79, 81),
                  a=factor(rep(c("A1", "A2"), each = 24)),
                  b=factor(rep(c("B1", "B2", "B3"), each=8, times=2)))
x.aov <- aov(x ~ a*b, data=tmp)
summary(x.aov)


## your request
require(multcomp)
tmp$ab <- with(tmp, interaction(a, b))
xi.aov <- aov(x ~ ab, data=tmp)
summary(xi.aov)
xi.glht <- glht(xi.aov, linfct=mcp(ab="Tukey"))
confint(xi.glht)


## graphs
## boxplots
require(lattice)
bwplot(x ~ ab, data=tmp)


## interaction plot
## install.packages("HH")  ## if you don't have HH yet
require(HH)
interaction2wt(x ~ a*b, data=tmp)


On Wed, Apr 4, 2012 at 1:10 PM, Jinsong Zhao <jszhao@yeah.net> wrote:

> On 2012-04-03 20:03, Rmh wrote:
>
>> yes.  See ?glht in the multcomp package, and the examples using glht in
>> ?MMC in the HH package.
>>
>> Sent from my iPhone
>>
>>
> Thank you very much for the clues. However, I can't figure out how to
> construct the linfct in glht.
>
> I also tried to inverse the computation based on:
> http://www.gigawiz.com/**images12/twowayrmposthoc.jpg<http://www.gigawiz.com/images12/twowayrmposthoc.jpg>
> However, I can't catch the MSE used in the above figure.
>
> Regards,
> Jinsong
>
>

	[[alternative HTML version deleted]]

______________________________________________
R-help@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.


	[[alternative HTML version deleted]]

