chap4demo <- read_excel("chap4demo.xlsx")
chap4demo$Trt <- factor(chap4demo$fertilizer)
head(chap4demo)
## # A tibble: 6 × 4
## trt fertilizer yield Trt
## <chr> <dbl> <dbl> <fct>
## 1 T1 0 4.89 0
## 2 T1 0 4.79 0
## 3 T1 0 4.65 0
## 4 T1 0 4.47 0
## 5 T2 50 5.08 50
## 6 T2 50 5.19 50
aov1 <- with(chap4demo, aov(yield ~ Trt))
anova(aov1)
## Analysis of Variance Table
##
## Response: yield
## Df Sum Sq Mean Sq F value Pr(>F)
## Trt 5 1.3555 0.271107 19.567 1.04e-06 ***
## Residuals 18 0.2494 0.013856
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
LSD.test(y = aov1,
trt = "Trt",
group = TRUE,
console = TRUE)
##
## Study: aov1 ~ "Trt"
##
## LSD t Test for yield
##
## Mean Square Error: 0.01385556
##
## Trt, means and individual ( 95 %) CI
##
## yield std r LCL UCL Min Max
## 0 4.70 0.18220867 4 4.576351 4.823649 4.47 4.89
## 100 5.23 0.03559026 4 5.106351 5.353649 5.18 5.26
## 150 5.38 0.06164414 4 5.256351 5.503649 5.31 5.46
## 200 5.36 0.13190906 4 5.236351 5.483649 5.25 5.55
## 250 5.28 0.08755950 4 5.156351 5.403649 5.21 5.40
## 50 5.02 0.14071247 4 4.896351 5.143649 4.89 5.19
##
## Alpha: 0.05 ; DF Error: 18
## Critical Value of t: 2.100922
##
## least Significant Difference: 0.1748666
##
## Treatments with the same letter are not significantly different.
##
## yield groups
## 150 5.38 a
## 200 5.36 a
## 250 5.28 a
## 100 5.23 a
## 50 5.02 b
## 0 4.70 c
scheffe.test(y = aov1,
trt = "Trt",
group = TRUE,
console = TRUE)
##
## Study: aov1 ~ "Trt"
##
## Scheffe Test for yield
##
## Mean Square Error : 0.01385556
##
## Trt, means
##
## yield std r Min Max
## 0 4.70 0.18220867 4 4.47 4.89
## 100 5.23 0.03559026 4 5.18 5.26
## 150 5.38 0.06164414 4 5.31 5.46
## 200 5.36 0.13190906 4 5.25 5.55
## 250 5.28 0.08755950 4 5.21 5.40
## 50 5.02 0.14071247 4 4.89 5.19
##
## Alpha: 0.05 ; DF Error: 18
## Critical Value of F: 2.772853
##
## Minimum Significant Difference: 0.309917
##
## Means with the same letter are not significantly different.
##
## yield groups
## 150 5.38 a
## 200 5.36 a
## 250 5.28 ab
## 100 5.23 ab
## 50 5.02 b
## 0 4.70 c
HSD.test(y = aov1,
trt = "Trt",
group = TRUE,
console = TRUE)
##
## Study: aov1 ~ "Trt"
##
## HSD Test for yield
##
## Mean Square Error: 0.01385556
##
## Trt, means
##
## yield std r Min Max
## 0 4.70 0.18220867 4 4.47 4.89
## 100 5.23 0.03559026 4 5.18 5.26
## 150 5.38 0.06164414 4 5.31 5.46
## 200 5.36 0.13190906 4 5.25 5.55
## 250 5.28 0.08755950 4 5.21 5.40
## 50 5.02 0.14071247 4 4.89 5.19
##
## Alpha: 0.05 ; DF Error: 18
## Critical Value of Studentized Range: 4.49442
##
## Minimun Significant Difference: 0.2645182
##
## Treatments with the same letter are not significantly different.
##
## yield groups
## 150 5.38 a
## 200 5.36 a
## 250 5.28 ab
## 100 5.23 ab
## 50 5.02 b
## 0 4.70 c
SNK.test(y = aov1,
trt = "Trt",
group = TRUE,
console = TRUE)
##
## Study: aov1 ~ "Trt"
##
## Student Newman Keuls Test
## for yield
##
## Mean Square Error: 0.01385556
##
## Trt, means
##
## yield std r Min Max
## 0 4.70 0.18220867 4 4.47 4.89
## 100 5.23 0.03559026 4 5.18 5.26
## 150 5.38 0.06164414 4 5.31 5.46
## 200 5.36 0.13190906 4 5.25 5.55
## 250 5.28 0.08755950 4 5.21 5.40
## 50 5.02 0.14071247 4 4.89 5.19
##
## Alpha: 0.05 ; DF Error: 18
##
## Critical Range
## 2 3 4 5 6
## 0.1748666 0.2124249 0.2352414 0.2516804 0.2645182
##
## Means with the same letter are not significantly different.
##
## yield groups
## 150 5.38 a
## 200 5.36 a
## 250 5.28 a
## 100 5.23 a
## 50 5.02 b
## 0 4.70 c
duncan.test(y = aov1,
trt = "Trt",
group = TRUE,
console = TRUE)
##
## Study: aov1 ~ "Trt"
##
## Duncan's new multiple range test
## for yield
##
## Mean Square Error: 0.01385556
##
## Trt, means
##
## yield std r Min Max
## 0 4.70 0.18220867 4 4.47 4.89
## 100 5.23 0.03559026 4 5.18 5.26
## 150 5.38 0.06164414 4 5.31 5.46
## 200 5.36 0.13190906 4 5.25 5.55
## 250 5.28 0.08755950 4 5.21 5.40
## 50 5.02 0.14071247 4 4.89 5.19
##
## Alpha: 0.05 ; DF Error: 18
##
## Critical Range
## 2 3 4 5 6
## 0.1748666 0.1834731 0.1889036 0.1926667 0.1954172
##
## Means with the same letter are not significantly different.
##
## yield groups
## 150 5.38 a
## 200 5.36 a
## 250 5.28 a
## 100 5.23 a
## 50 5.02 b
## 0 4.70 c
with(chap4demo, crd(treat = Trt,
resp = yield,
quali = TRUE,
mcomp = "lsd"))
## ------------------------------------------------------------------------
## Analysis of Variance Table
## ------------------------------------------------------------------------
## DF SS MS Fc Pr>Fc
## Treatament 5 1.3555 0.271107 19.567 1.0399e-06
## Residuals 18 0.2494 0.013856
## Total 23 1.6049
## ------------------------------------------------------------------------
## CV = 2.28 %
##
## ------------------------------------------------------------------------
## Shapiro-Wilk normality test
## p-value: 0.6315903
## According to Shapiro-Wilk normality test at 5% of significance, residuals can be considered normal.
## ------------------------------------------------------------------------
##
## ------------------------------------------------------------------------
## Homogeneity of variances test
## p-value: 0.1868725
## According to the test of bartlett at 5% of significance, residuals can be considered homocedastic.
## ------------------------------------------------------------------------
##
## T test (LSD)
## ------------------------------------------------------------------------
## Groups Treatments Means
## a 150 5.38
## a 200 5.36
## a 250 5.28
## a 100 5.23
## b 50 5.02
## c 0 4.7
## ------------------------------------------------------------------------
with(chap4demo, crd(treat = Trt,
resp = yield,
quali = TRUE,
mcomp = "tukey"))
## ------------------------------------------------------------------------
## Analysis of Variance Table
## ------------------------------------------------------------------------
## DF SS MS Fc Pr>Fc
## Treatament 5 1.3555 0.271107 19.567 1.0399e-06
## Residuals 18 0.2494 0.013856
## Total 23 1.6049
## ------------------------------------------------------------------------
## CV = 2.28 %
##
## ------------------------------------------------------------------------
## Shapiro-Wilk normality test
## p-value: 0.6315903
## According to Shapiro-Wilk normality test at 5% of significance, residuals can be considered normal.
## ------------------------------------------------------------------------
##
## ------------------------------------------------------------------------
## Homogeneity of variances test
## p-value: 0.1868725
## According to the test of bartlett at 5% of significance, residuals can be considered homocedastic.
## ------------------------------------------------------------------------
##
## Tukey's test
## ------------------------------------------------------------------------
## Groups Treatments Means
## a 150 5.38
## a 200 5.36
## ab 250 5.28
## ab 100 5.23
## b 50 5.02
## c 0 4.7
## ------------------------------------------------------------------------
with(chap4demo, crd(treat = Trt,
resp = yield,
quali = TRUE,
mcomp = "snk"))
## ------------------------------------------------------------------------
## Analysis of Variance Table
## ------------------------------------------------------------------------
## DF SS MS Fc Pr>Fc
## Treatament 5 1.3555 0.271107 19.567 1.0399e-06
## Residuals 18 0.2494 0.013856
## Total 23 1.6049
## ------------------------------------------------------------------------
## CV = 2.28 %
##
## ------------------------------------------------------------------------
## Shapiro-Wilk normality test
## p-value: 0.6315903
## According to Shapiro-Wilk normality test at 5% of significance, residuals can be considered normal.
## ------------------------------------------------------------------------
##
## ------------------------------------------------------------------------
## Homogeneity of variances test
## p-value: 0.1868725
## According to the test of bartlett at 5% of significance, residuals can be considered homocedastic.
## ------------------------------------------------------------------------
##
## Student-Newman-Keuls's test (SNK)
## ------------------------------------------------------------------------
## Groups Treatments Means
## a 150 5.38
## a 200 5.36
## a 250 5.28
## a 100 5.23
## b 50 5.02
## c 0 4.7
## ------------------------------------------------------------------------
with(chap4demo, crd(treat = Trt,
resp = yield,
quali = TRUE,
mcomp = "duncan"))
## ------------------------------------------------------------------------
## Analysis of Variance Table
## ------------------------------------------------------------------------
## DF SS MS Fc Pr>Fc
## Treatament 5 1.3555 0.271107 19.567 1.0399e-06
## Residuals 18 0.2494 0.013856
## Total 23 1.6049
## ------------------------------------------------------------------------
## CV = 2.28 %
##
## ------------------------------------------------------------------------
## Shapiro-Wilk normality test
## p-value: 0.6315903
## According to Shapiro-Wilk normality test at 5% of significance, residuals can be considered normal.
## ------------------------------------------------------------------------
##
## ------------------------------------------------------------------------
## Homogeneity of variances test
## p-value: 0.1868725
## According to the test of bartlett at 5% of significance, residuals can be considered homocedastic.
## ------------------------------------------------------------------------
##
## Duncan's test
## ------------------------------------------------------------------------
## Groups Treatments Means
## a 150 5.38
## a 200 5.36
## a 250 5.28
## a 100 5.23
## b 50 5.02
## c 0 4.7
## ------------------------------------------------------------------------
Suppose we are interested in testing the following comparisons:
What are the coefficients of each comparison?
Are the comparisons linear contrasts?
Is the above set of comparison orthogonal?
c1 <- rbind("Control (T1) vs Treated (T2 thru T6)" = c(5, -1, -1, -1, -1, -1))
summary(glht(aov1,linfct=mcp(Trt = c1)))
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: User-defined Contrasts
##
##
## Fit: aov(formula = yield ~ Trt)
##
## Linear Hypotheses:
## Estimate Std. Error t value Pr(>|t|)
## Control (T1) vs Treated (T2 thru T6) == 0 -2.7700 0.3224 -8.593 8.73e-08
##
## Control (T1) vs Treated (T2 thru T6) == 0 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
c2 <- rbind("(T2,T3) vs (T4, T5, T6)" = c(0, 3, 3, -2, -2, -2))
summary(glht(aov1,linfct=mcp(Trt = c2)))
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: User-defined Contrasts
##
##
## Fit: aov(formula = yield ~ Trt)
##
## Linear Hypotheses:
## Estimate Std. Error t value Pr(>|t|)
## (T2,T3) vs (T4, T5, T6) == 0 -1.2900 0.3224 -4.002 0.000837 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
line <- rbind("Linear trend" = c(-5, -3, -1, 1, 3, 5))
summary(glht(aov1,linfct=mcp(Trt = line)))
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: User-defined Contrasts
##
##
## Fit: aov(formula = yield ~ Trt)
##
## Linear Hypotheses:
## Estimate Std. Error t value Pr(>|t|)
## Linear trend == 0 4.0700 0.4924 8.265 1.53e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
quad <- rbind("Quadratic trend" = c(5, -1, -4, -4, -1, 5))
summary(glht(aov1,linfct=mcp(Trt = quad)))
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: User-defined Contrasts
##
##
## Fit: aov(formula = yield ~ Trt)
##
## Linear Hypotheses:
## Estimate Std. Error t value Pr(>|t|)
## Quadratic trend == 0 -2.9200 0.5394 -5.413 3.83e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- single-step method)
cube <- rbind("Cubic trend" = c(-5, 7, 4, -4, -7, 5))
summary(glht(aov1,linfct=mcp(Trt = cube)))
##
## Simultaneous Tests for General Linear Hypotheses
##
## Multiple Comparisons of Means: User-defined Contrasts
##
##
## Fit: aov(formula = yield ~ Trt)
##
## Linear Hypotheses:
## Estimate Std. Error t value Pr(>|t|)
## Cubic trend == 0 -0.0800 0.7896 -0.101 0.92
## (Adjusted p values reported -- single-step method)