library(statforbiology)
library(emmeans)
library(multcomp)
library(tidyverse)
library(car)
dataset <- getAgroData("mixture") |>
mutate(Treat = factor(Treat))
lm1 <- lm(Weight ~ Treat, data = dataset)
Anova(lm1)
Anova Table (Type II tests)
Response: Weight
Sum Sq Df F value Pr(>F)
Treat 1089.53 3 23.663 2.509e-05 ***
Residuals 184.18 12
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(lm1)
Call:
lm(formula = Weight ~ Treat, data = dataset)
Residuals:
Min 1Q Median 3Q Max
-6.360 -2.469 0.380 2.567 6.025
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.175 1.959 4.684 0.000529 ***
TreatMixture_378 -4.047 2.770 -1.461 0.169679
TreatRimsulfuron_30 7.685 2.770 2.774 0.016832 *
TreatUnweeded 17.598 2.770 6.352 3.65e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.918 on 12 degrees of freedom
Multiple R-squared: 0.8554, Adjusted R-squared: 0.8193
F-statistic: 23.66 on 3 and 12 DF, p-value: 2.509e-05
groupMeans <- emmeans(lm1, ~ Treat)
These two are the same (adjust = “tukey” is the default) – Tukey’s HSD for balanced data and Tukey–Kramer test for unbalanced data:
contrast(groupMeans, method = "pairwise")
contrast estimate SE df t.ratio p.value
Metribuzin__348 - Mixture_378 4.05 2.77 12 1.461 0.4885
Metribuzin__348 - Rimsulfuron_30 -7.68 2.77 12 -2.774 0.0698
Metribuzin__348 - Unweeded -17.60 2.77 12 -6.352 0.0002
Mixture_378 - Rimsulfuron_30 -11.73 2.77 12 -4.235 0.0055
Mixture_378 - Unweeded -21.64 2.77 12 -7.813 <0.0001
Rimsulfuron_30 - Unweeded -9.91 2.77 12 -3.578 0.0173
P value adjustment: tukey method for comparing a family of 4 estimates
contrast(groupMeans, method = "pairwise", adjust = "tukey")
contrast estimate SE df t.ratio p.value
Metribuzin__348 - Mixture_378 4.05 2.77 12 1.461 0.4885
Metribuzin__348 - Rimsulfuron_30 -7.68 2.77 12 -2.774 0.0698
Metribuzin__348 - Unweeded -17.60 2.77 12 -6.352 0.0002
Mixture_378 - Rimsulfuron_30 -11.73 2.77 12 -4.235 0.0055
Mixture_378 - Unweeded -21.64 2.77 12 -7.813 <0.0001
Rimsulfuron_30 - Unweeded -9.91 2.77 12 -3.578 0.0173
P value adjustment: tukey method for comparing a family of 4 estimates
And the same again with multivariate t-distribution
contrast(groupMeans, method = "pairwise", adjust = "mvt")
contrast estimate SE df t.ratio p.value
Metribuzin__348 - Mixture_378 4.05 2.77 12 1.461 0.4886
Metribuzin__348 - Rimsulfuron_30 -7.68 2.77 12 -2.774 0.0697
Metribuzin__348 - Unweeded -17.60 2.77 12 -6.352 0.0002
Mixture_378 - Rimsulfuron_30 -11.73 2.77 12 -4.235 0.0056
Mixture_378 - Unweeded -21.64 2.77 12 -7.813 <0.0001
Rimsulfuron_30 - Unweeded -9.91 2.77 12 -3.578 0.0172
P value adjustment: mvt method for 6 tests
Very similar results. The mvt method is “not recommended for pairwise comparisons in balanced experiments, whereas it may prove useful in other situations, for example in the presence of strongly unbalanced data.”