Skip to content

Commit

Permalink
goodness.cca failed for rank=1 component
Browse files Browse the repository at this point in the history
reported as issue #189 in github

(cherry picked from commit 07f1857)
  • Loading branch information
Jari Oksanen committed Aug 30, 2016
1 parent 433f527 commit 88299e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions R/goodness.cca.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
6 changes: 4 additions & 2 deletions R/inertcomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 88299e1

Please sign in to comment.