[S] multicomp() question

Thu, 16 Jul 1998 10:24:39 EDT

Dear S+ news group

I am an experienced programmer who is new to S+ and I am having trouble
getting results out of multicomp(). Below I have included a script which I
wrote to illustrate the problem. The script creates data for a 2X2X2 factorial
analysis which has an unambiguous three way interaction. The script is
commented, and it produces all necessary data for the analysis.

The result I get from the call to multicomp() on the last line of the script
is an LSD comparison on the first factor. I evidently need to specify the
desired three way comparison, but none of the illustrations I have found deal
with this situation. I would greatly appreciate someone sending me an example
of how to call multicomp to perform a Tukey HSD test on all the levels of
multiple factors.

Phil Gleason

# define three factors, and the number of levels (2 in each case) for
# each factor
str.nlvls <- 2
pos.nlvls <- 2
blk.nlvls <- 2
nreps <- 5 # the number of replications

### concoct means for each combination of levels which will produce
# a three way interaction
param.means <-

# name the factors and the levels of each factor
dimnames(param.means) <-

# create a data set
art.design <-
depvar <- vector(mode="numeric",length=dim(art.design)[1])
art.synth <- data.frame(art.design,depvar=depvar)

for (str.lvls in levels(art.synth$str)) {
for (pos.lvls in levels(art.synth$pos)) {
for (blk.lvls in levels(art.synth$blk)) {
art.synth[art.synth$str==str.lvls & art.synth$pos==pos.lvls &
"depvar"] <- param.means[str.lvls,pos.lvls,blk.lvls] + rnorm(nreps,0,0.1)

# check the aggregate means
agg.means <-

# now do the ANOVA
art.anova <- aov("depvar~str*pos*blk",data=art.synth,na.action=na.omit)

### art.summary shows a three way interaction
art.summary <- summary(art.anova)

# here is the problem. What do I pass to "multicomp" to have it
# assess the three way interaction? This call returns only an LSD
# comparison on one of the factors (the first one).
art.tukey <- multicomp.lm(art.anova,method="tukey")

This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news