## This example is from Hsu and Peruggia
## This is the R version
## See ?mmc.mean for S-Plus
if.R(s={},
r={
pulmonary <- read.table(hh("datasets/pulmonary.dat"), header=TRUE,
row.names=NULL)
names(pulmonary)[3] <- "FVC"
names(pulmonary)[1] <- "smoker"
pulmonary$smoker <- factor(pulmonary$smoker, levels=pulmonary$smoker)
row.names(pulmonary) <- pulmonary$smoker
pulmonary
pulmonary.aov <- aov.sufficient(FVC ~ smoker,
data=pulmonary)
summary(pulmonary.aov)
pulmonary.mmc <- glht.mmc(pulmonary.aov,
linfct=mcp(smoker="Tukey"),
df=pulmonary.aov$df.residual,
vcov.=vcov.sufficient)
old.omd <- par(omd=c(.03,.95,0,1))
plot(pulmonary.mmc)
## tiebreaker plot, with contrasts ordered to match MMC plot,
## with all contrasts forced positive and with names also reversed,
## and with matched x-scale.
plot.matchMMC(pulmonary.mmc$mca)
## orthogonal contrasts
pulm.lmat <- cbind("npnl-mh"=c( 1, 1, 1, 1,-2,-2), ## not.much vs lots
"n-pnl" =c( 3,-1,-1,-1, 0, 0), ## none vs light
"p-nl" =c( 0, 2,-1,-1, 0, 0), ## {} arbitrary 2 df
"n-l" =c( 0, 0, 1,-1, 0, 0), ## {} for 3 types of light
"m-h" =c( 0, 0, 0, 0, 1,-1)) ## moderate vs heavy
dimnames(pulm.lmat)[[1]] <- row.names(pulmonary)
pulm.lmat
pulmonary.mmc <- glht.mmc(pulmonary.aov,
linfct=mcp(smoker="Tukey"),
df=pulmonary.aov$df.residual,
vcov.=vcov.sufficient,
focus.lmat=pulm.lmat)
plot(pulmonary.mmc)
plot.matchMMC(pulmonary.mmc$lmat, col.signif='blue')
## pairwise and orthogonal contrasts on the same plot
plot(pulmonary.mmc, print.mca=TRUE, print.lmat=TRUE)
par(old.omd)
})
Run the code above in your browser using DataCamp Workspace