waste.RdIndustrial waste output in a manufactoring plant.
data("waste")This data frame contains the following variables
temperature, a factor at three levels: low, medium, high.
environment, a factor at five levels: env1 ... env5.
response variable: waste output in a manufacturing plant.
The data are from an experiment designed to study the effect of temperature
(temp) and environment (envir) on waste output in a manufactoring plant.
Two replicate measurements were taken at each temperature / environment combination.
P. H. Westfall, R. D. Tobias, D. Rom, R. D. Wolfinger, Y. Hochberg (1999). Multiple Comparisons and Multiple Tests Using the SAS System. Cary, NC: SAS Institute Inc., page 177.
### set up two-way ANOVA with interactions
amod <- aov(waste ~ temp * envir, data=waste)
### comparisons of main effects only
K <- glht(amod, linfct = mcp(temp = "Tukey"))$linfct
#> Warning: covariate interactions found -- default contrast might be inappropriate
K
#> (Intercept) templow tempmedium envirenv2 envirenv3 envirenv4
#> low - high 0 1 0 0 0 0
#> medium - high 0 0 1 0 0 0
#> medium - low 0 -1 1 0 0 0
#> envirenv5 templow:envirenv2 tempmedium:envirenv2
#> low - high 0 0 0
#> medium - high 0 0 0
#> medium - low 0 0 0
#> templow:envirenv3 tempmedium:envirenv3 templow:envirenv4
#> low - high 0 0 0
#> medium - high 0 0 0
#> medium - low 0 0 0
#> tempmedium:envirenv4 templow:envirenv5 tempmedium:envirenv5
#> low - high 0 0 0
#> medium - high 0 0 0
#> medium - low 0 0 0
#> attr(,"type")
#> [1] "Tukey"
glht(amod, K)
#>
#> General Linear Hypotheses
#>
#> Multiple Comparisons of Means: Tukey Contrasts
#>
#>
#> Linear Hypotheses:
#> Estimate
#> low - high == 0 -1.26
#> medium - high == 0 -1.34
#> medium - low == 0 -0.08
#>
### comparisons of means (by averaging interaction effects)
low <- grep("low:envi", colnames(K))
med <- grep("medium:envi", colnames(K))
K[1, low] <- 1 / (length(low) + 1)
K[2, med] <- 1 / (length(low) + 1)
K[3, med] <- 1 / (length(low) + 1)
K[3, low] <- - 1 / (length(low) + 1)
K
#> (Intercept) templow tempmedium envirenv2 envirenv3 envirenv4
#> low - high 0 1 0 0 0 0
#> medium - high 0 0 1 0 0 0
#> medium - low 0 -1 1 0 0 0
#> envirenv5 templow:envirenv2 tempmedium:envirenv2
#> low - high 0 0.2 0.0
#> medium - high 0 0.0 0.2
#> medium - low 0 -0.2 0.2
#> templow:envirenv3 tempmedium:envirenv3 templow:envirenv4
#> low - high 0.2 0.0 0.2
#> medium - high 0.0 0.2 0.0
#> medium - low -0.2 0.2 -0.2
#> tempmedium:envirenv4 templow:envirenv5 tempmedium:envirenv5
#> low - high 0.0 0.2 0.0
#> medium - high 0.2 0.0 0.2
#> medium - low 0.2 -0.2 0.2
#> attr(,"type")
#> [1] "Tukey"
confint(glht(amod, K))
#>
#> Simultaneous Confidence Intervals
#>
#> Multiple Comparisons of Means: Tukey Contrasts
#>
#>
#> Fit: aov(formula = waste ~ temp * envir, data = waste)
#>
#> Quantile = 2.6
#> 95% family-wise confidence level
#>
#>
#> Linear Hypotheses:
#> Estimate lwr upr
#> low - high == 0 -2.0150 -3.2753 -0.7547
#> medium - high == 0 -2.2560 -3.5163 -0.9957
#> medium - low == 0 -0.2410 -1.5013 1.0193
#>
### same as TukeyHSD
TukeyHSD(amod, "temp")
#> Tukey multiple comparisons of means
#> 95% family-wise confidence level
#>
#> Fit: aov(formula = waste ~ temp * envir, data = waste)
#>
#> $temp
#> diff lwr upr p adj
#> low-high -2.015 -3.274054 -0.7559457 0.0022853
#> medium-high -2.256 -3.515054 -0.9969457 0.0008562
#> medium-low -0.241 -1.500054 1.0180543 0.8737275
#>
### set up linear hypotheses for all-pairs of both factors
wht <- glht(amod, linfct = mcp(temp = "Tukey", envir = "Tukey"))
#> Warning: covariate interactions found -- default contrast might be inappropriate
#> Warning: covariate interactions found -- default contrast might be inappropriate
### cf. Westfall et al. (1999, page 181)
summary(wht, test = adjusted("Shaffer"))
#>
#> Simultaneous Tests for General Linear Hypotheses
#>
#> Multiple Comparisons of Means: Tukey Contrasts
#>
#>
#> Fit: aov(formula = waste ~ temp * envir, data = waste)
#>
#> Linear Hypotheses:
#> Estimate Std. Error t value Pr(>|t|)
#> temp: low - high == 0 -1.260 1.084 -1.162 1.000
#> temp: medium - high == 0 -1.340 1.084 -1.236 1.000
#> temp: medium - low == 0 -0.080 1.084 -0.074 1.000
#> envir: env2 - env1 == 0 1.830 1.084 1.688 0.784
#> envir: env3 - env1 == 0 1.330 1.084 1.227 1.000
#> envir: env4 - env1 == 0 3.805 1.084 3.511 0.041 *
#> envir: env5 - env1 == 0 3.660 1.084 3.377 0.041 *
#> envir: env3 - env2 == 0 -0.500 1.084 -0.461 1.000
#> envir: env4 - env2 == 0 1.975 1.084 1.822 0.619
#> envir: env5 - env2 == 0 1.830 1.084 1.688 0.784
#> envir: env4 - env3 == 0 2.475 1.084 2.283 0.337
#> envir: env5 - env3 == 0 2.330 1.084 2.150 0.337
#> envir: env5 - env4 == 0 -0.145 1.084 -0.134 1.000
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> (Adjusted p values reported -- Shaffer method)
#>