# NOT RUN {
data(vargas.wheat2)
dat <- vargas.wheat2
yield <- dat$yield
covs <- dat$covs
# The pls package centers, but does not (by default) use scaled covariates
# Vargas says you should
# yield <- scale(yield)
covs <- scale(covs)
require(pls)
m2 <- plsr(yield ~ covs)
# Plot predicted vs observed for each genotype using all components
plot(m2)
# Loadings
# plot(m2, "loadings", xaxt='n')
# axis(1, at=1:ncol(covs), labels=colnames(covs), las=2)
# Biplots
biplot(m2, cex=.5, which="y", var.axes=TRUE,
main="vargas.wheat2 - yield ~ covs") # Vargas figure 2a
biplot(m2, cex=.5, which="x", var.axes=TRUE) # Vectors form figure 2 b
# biplot(m2, cex=.5, which="scores", var.axes=TRUE)
# biplot(m2, cex=.5, which="loadings", var.axes=TRUE)
# }
Run the code above in your browser using DataLab