Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contingency matrix with columns of only 0s #11

Open
Jorge-C opened this issue Jan 30, 2014 · 1 comment
Open

Contingency matrix with columns of only 0s #11

Jorge-C opened this issue Jan 30, 2014 · 1 comment

Comments

@Jorge-C
Copy link
Owner

Jorge-C commented Jan 30, 2014

Current CCA code fails if the contingency matrix has any column with no observations, but vegan's R doesn't.

However, in R both sol and sol2 have the same results (Yval has a few columns with no observations):

library(vegan)
X <- read.table('Xval')
Y <- read.table('Yval')

nonzero <- apply(Y, 2, sum) != 0

sol <- cca(Y[, nonzero], X)
sol2 <- cca(Y, X)

and they match the current python implementation

from ordination import CCA
import numpy as np

X = np.loadtxt('Xval')
Y = np.loadtxt('Yval')

nonzero = Y.sum(axis=0) != 0

sol = CCA(Y[:, nonzero], X)

Maybe we can just remove those columns in __init__ and be careful with names (warning the user "hey, {n_cols} of the contingency matrix had no observations, they were dropped in the analysis.")

@Jorge-C
Copy link
Owner Author

Jorge-C commented Jan 30, 2014

Also, test what happens in RDA/CA with same kind of data, and compare to vegan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant