diff --git a/R/goodness.cca.R b/R/goodness.cca.R index cf968471c..c21eb2fc3 100644 --- a/R/goodness.cca.R +++ b/R/goodness.cca.R @@ -33,8 +33,12 @@ else pCCA <- diag(crossprod(pCCA))/nr } - CA <- t(apply(diag(w) %*% CA^2 %*% diag(eig), 1, - cumsum)) + CA <- t(apply( + diag(w, length(w)) %*% CA^2 %*% diag(eig, length(eig)), + 1, cumsum)) + ## rank=1 solutions comes out transposed: back transpose + if (length(eig) == 1) + CA <- t(CA) totals <- inertcomp(object, display = display) comps <- colnames(totals) if (statistic == "explained") { diff --git a/R/inertcomp.R b/R/inertcomp.R index e6591d3ae..c3acc1d99 100644 --- a/R/inertcomp.R +++ b/R/inertcomp.R @@ -40,9 +40,11 @@ pCCA <- diag(crossprod(pCCA))/nr } if (!is.null(CCA)) - CCA <- rowSums(diag(w) %*% CCA^2 %*% diag(object$CCA$eig)) + CCA <- rowSums(diag(w, length(w)) %*% CCA^2 %*% + diag(object$CCA$eig, length(object$CCA$eig))) if (!is.null(CA)) - CA <- rowSums(diag(w) %*% CA^2 %*% diag(object$CA$eig)) + CA <- rowSums(diag(w, length(w)) %*% CA^2 %*% + diag(object$CA$eig, length(object$CA$eig))) out <- cbind(pCCA, CCA, CA) if (statistic == "distance" && !proportional) { w <- weights(object, display = display)