Hi all I´m trying to tests the significance of loadings from a ordination of 46 variables (caategorical, ordinal and nominal). I used dudi.mix from ade4 for the ordination. A years ago Jari Oksanen wrote this script implementing Peres-Neto et al. 2003 (Ecology) bootstraping method:
netoboot <- function (x, permutations=1000, ...) { pcnull <- princomp(x, cor = TRUE, ...) res <- pcnull$loadings out <- matrix(0, nrow=nrow(res), ncol=ncol(res)) N <- nrow(x) for (i in 1:permutations) { pc <- princomp(x[sample(N, replace=TRUE), ], cor = TRUE ...) pred <- predict(pc, newdata = x) r <- cor(pcnull$scores, pred) k <- apply(abs(r), 2, which.max) reve <- sign(diag(r[k,])) sol <- pc$loadings[ ,k] sol <- sweep(sol, 2, reve, "*") out <- out + ifelse(res > 0, sol <= 0, sol >= 0) } out/permutations } I tried to aply it to the case of dudi.mix instead of princomp this way: netoboot1<-function (x, permutations=1000,...) { dudinull <- dudi.mix(x, scannf = FALSE, nf = 3) res <- dudinull$c1 out <- matrix(0, nrow=nrow(res), ncol=ncol(res)) N <- nrow(x) for (i in 1:permutations) { dudi <- dudi.mix(x[sample(N, replace=TRUE), ], scannf = FALSE, nf = 3) pred <- predict(dudi, newdata = x) r <- cor(dudinull$li, pred) k <- apply(abs(r), 2, which.max) reve <- sign(diag(r[k,])) sol <- dudi$c1[ ,k] sol <- sweep(sol, 2, reve, "*") out <- out + ifelse(res > 0, sol <= 0, sol >= 0) } out/permutations } But a problem arised with the predict function: it doesn´t seem to work with an object from dudi.mix and I dont understand why. Can somebody tell me why? Any suggestions to modify the script or to use other method? Thanks in advance. Francisco Francisco Mora Ardila Laboratorio de Biodiversidad y Funcionamiento del Ecosistema Centro de Investigaciones en Ecosistemas UNAM-Campus Morelia Tel 3222777 ext. 42621 Morelia , MIchoacán, México. -- Open WebMail Project (http://openwebmail.org) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.