# Full replications
library(agricolae)
library(klaR)
# Example 1
data(ltrv)
#startgraph
# biplot
model<- AMMI(ltrv[,2], ltrv[,1], ltrv[,3], ltrv[,5],xlim=c(-3,3),ylim=c(-4,4),
graph="biplot")
model<- AMMI(ltrv[,2], ltrv[,1], ltrv[,3], ltrv[,5],xlim=c(-3,3),ylim=c(-4,4),
graph="biplot",number=FALSE)
# triplot
model<- AMMI(ltrv[,2], ltrv[,1], ltrv[,3], ltrv[,5],graph="triplot")
model<- AMMI(ltrv[,2], ltrv[,1], ltrv[,3], ltrv[,5],graph="triplot",number=FALSE)
#endgraph
# Example 2
data(CIC)
attach(CIC)
#startgraph
par(cex=0.6)
model<-AMMI(Environment, Genotype, Rep, Relative,xlim=c(-0.6,0.6),
ylim=c(-1.5e-8,1.5e-8))
#endgraph
pc<- princomp(model$genXenv, cor = FALSE)
pc$loadings
summary(pc)
model$biplot
detach(CIC)
# Example 3
# Only means. Mean square error is well-known.
data(sinRepAmmi)
attach(sinRepAmmi)
REP <- 3
MSerror <- 93.24224
#startgraph
model<-AMMI(ENV, GEN, REP, YLD, MSerror,xlim=c(-8,6),ylim=c(-6,6))
#endgraph
pc<- princomp(model$genXenv, cor = FALSE)
pc$loadings
summary(pc)
model$biplot
detach(sinRepAmmi)
# Biplot with the one restored observed.
rm(REP)
bplot<-model$biplot[,1:4]
attach(bplot)
#startgraph
par(cex=0.8)
plot(YLD,CP1,cex=0.0,text(YLD,CP1,labels=row.names(bplot),col="blue"),
main="AMMI BIPLOT",frame=TRUE)
media<-mean(YLD)
abline(h=0,v= media,lty=2,col="red")
amb<-subset(bplot,type=="ENV")
detach(bplot)
attach(amb)
s <- seq(length(YLD))
arrows(media, 0, 0.9*(YLD[s]-media)+media, 0.9*CP1[s], col= "brown",
lwd=1.8,length=0.1)
#endgraph
detach(amb)
# Principal components by means of the covariance
# It is to compare results with AMMI
cova<-cov(model$genXenv)
values<-eigen(cova)
total<-sum(values$values)
round(values$values*100/total,2)
# AMMI: 64.81 18.58 13.50 3.11 0.00
Run the code above in your browser using DataLab