Loading required packages
library(agricolae)
library(ExpDes)
##
## Attaching package: 'ExpDes'
## The following objects are masked from 'package:agricolae':
##
## lastC, order.group, tapply.stat
Reading and preparing the data
#RCBD without sub-sample
rcbd <- read.csv("rcbd.csv")
rcbd$Trt <- factor(rcbd$TRT)
rcbd$Block <- factor(rcbd$PLOT)
#RCBD with sub-samples
rcbdsub <- read.csv("rcbdsub.csv")
rcbdsub$Trt <- factor(rcbdsub$TRT)
rcbdsub$Block <- factor(rcbdsub$BLOCK)
#Latin square design
additives <- read.csv("additives.csv")
additives$Driver <- factor(additives$Driver)
additives$Car <- factor(additives$Car)
additives$Treatment <- additives$Trt
ANOVA for RCBD without sub-samples
out1 <- aov(SEEDLINGS ~ Trt + Block,
data = rcbd) #default aov () function
summary(out1)
## Df Sum Sq Mean Sq F value Pr(>F)
## Trt 2 1832 916.0 211.38 2.74e-06 ***
## Block 3 438 146.0 33.69 0.000377 ***
## Residuals 6 26 4.3
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
HSD.test(out1, "Trt", console =TRUE)#post-hoc for Trt effect
##
## Study: out1 ~ "Trt"
##
## HSD Test for SEEDLINGS
##
## Mean Square Error: 4.333333
##
## Trt, means
##
## SEEDLINGS std r Min Max
## 1 58 7.831560 4 48 66
## 2 87 7.788881 4 78 94
## 3 80 5.715476 4 72 85
##
## Alpha: 0.05 ; DF Error: 6
## Critical Value of Studentized Range: 4.339195
##
## Minimun Significant Difference: 4.516378
##
## Treatments with the same letter are not significantly different.
##
## SEEDLINGS groups
## 2 87 a
## 3 80 b
## 1 58 c
# Using the rbd() function in the ExpDes package
with(rcbd, rbd(Trt, Block, SEEDLINGS,
quali=TRUE,
mcomp="tukey"))
## ------------------------------------------------------------------------
## Analysis of Variance Table
## ------------------------------------------------------------------------
## DF SS MS Fc Pr>Fc
## Treatament 2 1832 916.00 211.385 0.00000274
## Block 3 438 146.00 33.692 0.00037669
## Residuals 6 26 4.33
## Total 11 2296
## ------------------------------------------------------------------------
## CV = 2.78 %
##
## ------------------------------------------------------------------------
## Shapiro-Wilk normality test
## p-value: 0.5130488
## According to Shapiro-Wilk normality test at 5% of significance, residuals can be considered normal.
## ------------------------------------------------------------------------
##
## ------------------------------------------------------------------------
## Homogeneity of variances test
## p-value: 0.7764982
## According to the test of oneillmathews at 5% of significance, the variances can be considered homocedastic.
## ------------------------------------------------------------------------
##
## Tukey's test
## ------------------------------------------------------------------------
## Groups Treatments Means
## a 2 87
## b 3 80
## c 1 58
## ------------------------------------------------------------------------
ANOVA for RCBD with sub-samples
out2 <- aov(worms ~ Trt + Block + Trt:Block,
data = rcbdsub)
summary(out2)
## Df Sum Sq Mean Sq F value Pr(>F)
## Trt 2 293.4 146.72 16.113 5.28e-06 ***
## Block 4 151.2 37.79 4.150 0.00603 **
## Trt:Block 8 196.2 24.53 2.694 0.01641 *
## Residuals 45 409.8 9.11
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
HSD.test(out2, "Trt", console = TRUE)
##
## Study: out2 ~ "Trt"
##
## HSD Test for worms
##
## Mean Square Error: 9.105556
##
## Trt, means
##
## worms std r Min Max
## c 5.25 2.935715 20 0 12
## control 9.70 5.068998 20 4 22
## s 4.80 2.353050 20 1 9
##
## Alpha: 0.05 ; DF Error: 45
## Critical Value of Studentized Range: 3.427507
##
## Minimun Significant Difference: 2.312686
##
## Treatments with the same letter are not significantly different.
##
## worms groups
## control 9.70 a
## c 5.25 b
## s 4.80 b
ANOVA for Latin Square Design
out3 <- aov(Reduction ~ Treatment + Driver + Car,
data = additives)
anova(out3)
## Analysis of Variance Table
##
## Response: Reduction
## Df Sum Sq Mean Sq F value Pr(>F)
## Treatment 3 40 13.333 2.5 0.156490
## Driver 3 216 72.000 13.5 0.004466 **
## Car 3 24 8.000 1.5 0.307174
## Residuals 6 32 5.333
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Using the latsd() function in the ExpDes package
with(additives, latsd(Treatment, Driver, Car, Reduction,
quali = TRUE,
mcomp = "tukey"))
## ------------------------------------------------------------------------
## Analysis of Variance Table
## ------------------------------------------------------------------------
## DF SS MS Fc Pr>Fc
## Treatament 3 40 13.333 2.5 0.156490
## Row 3 216 72.000 13.5 0.004466
## Column 3 24 8.000 1.5 0.307174
## Residuals 6 32 5.333
## Total 15 312
## ------------------------------------------------------------------------
## CV = 11.55 %
##
## ------------------------------------------------------------------------
## Shapiro-Wilk normality test
## p-value: 0.3260439
## According to Shapiro-Wilk normality test at 5% of significance, residuals can be considered normal.
## ------------------------------------------------------------------------
##
## According to the F test, the means can not be considered distinct.
## Levels Means
## 1 A 18
## 2 B 22
## 3 C 21
## 4 D 19
## ------------------------------------------------------------------------