Problem statement: An experiment was conducted in RCBD to study the comparative performance of fodder sorghum lines under rain fed conditions. Data is furnished below. Are all lines same? If not carry out LSD test and Duncan test to compare the lines
Importing the Dataset
library(readxl)
RBD <- read_excel("C:/1. School/School/4th Year/Experimental Design/Assignment/Finals/Seatwork 7 RCBD/RBD.xlsx")
RBD
## # A tibble: 20 x 3
## Replication Variety Yield
## <dbl> <chr> <dbl>
## 1 1 African tall 22.9
## 2 1 Co-11 29.5
## 3 1 FS-1 28.8
## 4 1 K-7 47
## 5 1 Co-24 28.9
## 6 2 African tall 25.9
## 7 2 Co-11 30.4
## 8 2 FS-1 24.4
## 9 2 K-7 40.9
## 10 2 Co-24 20.4
## 11 3 African tall 39.1
## 12 3 Co-11 35.3
## 13 3 FS-1 32.1
## 14 3 K-7 42.8
## 15 3 Co-24 21.1
## 16 4 African tall 33.9
## 17 4 Co-11 29.6
## 18 4 FS-1 28.6
## 19 4 K-7 32.1
## 20 4 Co-24 31.8
Fitting of linear model \(H_o\): African tall=Co-11=FS-1=K-7=Co-24, \(H_a\): At least one variety is different
model <- lm(RBD$Yield~ RBD$Replication+RBD$Variety)
model
##
## Call:
## lm(formula = RBD$Yield ~ RBD$Replication + RBD$Variety)
##
## Coefficients:
## (Intercept) RBD$Replication RBD$VarietyCo-11 RBD$VarietyCo-24
## 29.195 0.502 0.750 -4.900
## RBD$VarietyFS-1 RBD$VarietyK-7
## -1.975 10.250
Obtain ANOVA
anova <-anova(model)
anova
## Analysis of Variance Table
##
## Response: RBD$Yield
## Df Sum Sq Mean Sq F value Pr(>F)
## RBD$Replication 1 6.30 6.300 0.2072 0.65592
## RBD$Variety 4 520.53 130.133 4.2806 0.01808 *
## Residuals 14 425.61 30.401
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Discussion: From the result of the anova, the varieties are significantly different from one another at 0.05 level of significance. This further means that we reject the null hypothesis and accept the alternative hypothesis.
#Below codes are used to obtain plots of fitted vs Residuals and Normal QQ plots
par(mfrow=c(1,2))
plot(model, which=1)
plot(model, which=2)
Discussion: As shown in the Normal Q-Q plot, almost of the observations are on the line or near the line. Thus normality is fulfilled.
Duncan test
library(agricolae)
DNMRT <-duncan.test(RBD$Yield,RBD$Variety,12,29.259)
DNMRT
## $statistics
## MSerror Df Mean CV
## 29.259 12 31.275 17.29547
##
## $parameters
## test name.t ntr alpha
## Duncan RBD$Variety 5 0.05
##
## $duncan
## Table CriticalRange
## 2 3.081307 8.333639
## 3 3.225244 8.722927
## 4 3.312453 8.958792
## 5 3.370172 9.114897
##
## $means
## RBD$Yield std r Min Max Q25 Q50 Q75
## African tall 30.450 7.403378 4 22.9 39.1 25.150 29.90 35.200
## Co-11 31.200 2.762849 4 29.5 35.3 29.575 30.00 31.625
## Co-24 25.550 5.674798 4 20.4 31.8 20.925 25.00 29.625
## FS-1 28.475 3.155287 4 24.4 32.1 27.550 28.70 29.625
## K-7 40.700 6.274286 4 32.1 47.0 38.700 41.85 43.850
##
## $comparison
## NULL
##
## $groups
## RBD$Yield groups
## K-7 40.700 a
## Co-11 31.200 b
## African tall 30.450 b
## FS-1 28.475 b
## Co-24 25.550 b
##
## attr(,"class")
## [1] "group"
LSD test
LSD <-LSD.test(RBD$Yield,RBD$Variety,12,29.259)
LSD
## $statistics
## MSerror Df Mean CV t.value LSD
## 29.259 12 31.275 17.29547 2.178813 8.333639
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none RBD$Variety 5 0.05
##
## $means
## RBD$Yield std r LCL UCL Min Max Q25 Q50
## African tall 30.450 7.403378 4 24.55723 36.34277 22.9 39.1 25.150 29.90
## Co-11 31.200 2.762849 4 25.30723 37.09277 29.5 35.3 29.575 30.00
## Co-24 25.550 5.674798 4 19.65723 31.44277 20.4 31.8 20.925 25.00
## FS-1 28.475 3.155287 4 22.58223 34.36777 24.4 32.1 27.550 28.70
## K-7 40.700 6.274286 4 34.80723 46.59277 32.1 47.0 38.700 41.85
## Q75
## African tall 35.200
## Co-11 31.625
## Co-24 29.625
## FS-1 29.625
## K-7 43.850
##
## $comparison
## NULL
##
## $groups
## RBD$Yield groups
## K-7 40.700 a
## Co-11 31.200 b
## African tall 30.450 b
## FS-1 28.475 b
## Co-24 25.550 b
##
## attr(,"class")
## [1] "group"
#Save the file in txt
sink("RBD.txt")
print(anova)
## Analysis of Variance Table
##
## Response: RBD$Yield
## Df Sum Sq Mean Sq F value Pr(>F)
## RBD$Replication 1 6.30 6.300 0.2072 0.65592
## RBD$Variety 4 520.53 130.133 4.2806 0.01808 *
## Residuals 14 425.61 30.401
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
print("DNMRT Result")
## [1] "DNMRT Result"
print(DNMRT$statistics)
## MSerror Df Mean CV
## 29.259 12 31.275 17.29547
print(DNMRT$groups)
## RBD$Yield groups
## K-7 40.700 a
## Co-11 31.200 b
## African tall 30.450 b
## FS-1 28.475 b
## Co-24 25.550 b
print("LSD Result")
## [1] "LSD Result"
print(LSD$statistics)
## MSerror Df Mean CV t.value LSD
## 29.259 12 31.275 17.29547 2.178813 8.333639
print(LSD$groups)
## RBD$Yield groups
## K-7 40.700 a
## Co-11 31.200 b
## African tall 30.450 b
## FS-1 28.475 b
## Co-24 25.550 b
sink()