# NOT RUN {
# Yield
library(agricolae)
data(huasahuasi)
YIELD<-huasahuasi$YIELD
market <- YIELD$y1da + YIELD$y2da
non_market <- YIELD$y3da
yield <- market + non_market
model<-with(YIELD,strip.plot(block, clon, trt, yield))
comparison<-with(YIELD,LSD.test(yield,clon,model$gl.a,model$Ea))
comparison<-with(YIELD,LSD.test(yield,trt,model$gl.b,model$Eb))
# simple effects
A<-model$data
a<-nlevels(A$clon)
b<-nlevels(A$trt)
r<-nlevels(A$block)
Ea<-model$Ea; Eb<-model$Ec; Ec<-model$Ec;
gla<-model$gl.a; glb<-model$gl.b; glc<-model$gl.c;
B <-tapply.stat(A[,4],A[,2:3],mean)
std<-tapply.stat(A[,4],A[,2:3],function(x) sd(x)/sqrt(length(x)))
B<-data.frame(B[,1:2],yield=B[,3],std=std[,3])
cmab<-(b-1)*Ec + Ea
cmba<-(a-1)*Ec + Eb
# order.group
# Tukey
ta <- qtukey(0.95,a,gla)
tb <- qtukey(0.95,b,glb)
tc <- qtukey(0.95,a*b,glc)
tab<- ((b-1)*Ec*tc + Ea*ta)/cmab
tba<- ((a-1)*Ec*tc + Eb*tb)/cmba
# Comparison of clones by treatment
groups<-by(B,B[,2], function(x) order.group(x$clon,x$yield,N=b*r, cmab,tab,
std.err=x$std,parameter=0.5,console=FALSE))
groups
# Comparison of treatments by clon
groups<-by(B,B[,1], function(x) order.group(x$trt,x$yield,N=a*r,cmba,tba,
std.err=x$std,parameter=0.5,console=FALSE))
groups
# LSD t-student
ta <- qt(0.975,gla)
tb <- qt(0.975,glb)
tc <- qt(0.975,glc)
tab<- ((b-1)*Ec*tc + Ea*ta)/cmab
tba<- ((a-1)*Ec*tc + Eb*tb)/cmba
# Comparison of clones by treatment
groups<-by(B,B[,2], function(x) order.group(x$clon,x$yield,N=b*r,cmab,tab,
std.err=x$std,console=FALSE))
groups
# Comparison of treatments by clon
groups<-by(B,B[,1], function(x) order.group(x$trt,x$yield,N=a*r,cmba,tba,
std.err=x$std,console=FALSE))
groups
# }
Run the code above in your browser using DataLab