################################################### ### 2. Data manipulation ################################################### library("ade4") data("doubs", package = "ade4") Y <- doubs$fish X <- doubs$env blo <- c(4, 7) tab.names <- c("River", "Chemicals") ktabX <- ktab.data.frame(df = X, blocks = blo, tabnames = tab.names) dudiY <- dudi.pca(Y, center = TRUE, scale = TRUE, scannf = FALSE) data("chickenk", package = "ade4") losses <- chickenk[[1]] dudiY <- dudi.pca(losses, center = TRUE, scale = TRUE, scannf = FALSE) ktabX <- ktab.list.df(chickenk[2:5]) ################################################### ### 3. Multiblock methods ################################################### res <- mbpcaiv(dudiY, ktabX, scale = TRUE, option = "uniform", scannf = FALSE, nf = 5) res ################################################### ### 4. Descriptive interpretation tools ################################################### summary(res) library("adegraphics") plotmbpcaiv <- plot(res, xax = 1, yax = 2) class(plotmbpcaiv) mycol <- ifelse(ktabX$FlockCharacteristics$Stress == 0, "blue", "red") update(plotmbpcaiv[[1]], plabel.cex = 0, ppoints.col = mycol, paxes.draw = TRUE, pbackground.col = "lightgrey") ################################################### ### 5. Selection of the optimal number of latent variables ################################################### set.seed(123456) testdim.chik <- testdim(res, nrepet = 100) class(testdim.chik) plot(testdim.chik) ################################################### ### 6. Interpretation of the optimal model ################################################### set.seed(123456) boot.chik <- randboot(res, nrepet = 199, optdim = 4) class(boot.chik) names(boot.chik) class(boot.chik$vipc) g1 <- plot(boot.chik$XYcoef$Mort7, main = "Mort7", plot = FALSE) g2 <- plot(boot.chik$XYcoef$Mort, main = "Mort", plot = FALSE) g3 <- plot(boot.chik$XYcoef$Doa, main = "Doa", plot = FALSE) g4 <- plot(boot.chik$XYcoef$Condemn, main = "Condemn", plot = FALSE) ADEgS(list(g1, g2, g3, g4)) g5 <- plot(boot.chik$vipc, main = "vipc", plot = FALSE) g6 <- plot(boot.chik$bipc, main = "bipc", plot = FALSE) ADEgS(list(g5, g6))