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

Feature: Cor and Cov for Sparse Matrices #282

Closed
jeffwong opened this issue Jul 5, 2017 · 3 comments
Closed

Feature: Cor and Cov for Sparse Matrices #282

jeffwong opened this issue Jul 5, 2017 · 3 comments

Comments

@jeffwong
Copy link

jeffwong commented Jul 5, 2017

Hi, I am new to Julia and want to become a contributor. In my daily work I operate on sparse matrices every day, and need a sparse implementation for cor and cov. From what I can tell, there are only functions for computing cor and cov on dense matrices. I'd like to work on this functionality and contribute it to Julia. Were there any other plans that someone had in mind?

One of the challenges for computing cov is the fact that the input matrix needs to be centered and scaled. Centering a sparse matrix makes it dense again, which makes it sound like it defeats the purpose. However, we can write an implementation that operates on two data structures, the original sparse matrix X and a vector of means, m. We will be able to construct cov(X) by working on X-rep(m) and still be able to preserve some of the sparse operations. This is what happens in R's glmnet package.

@nalimilan
Copy link
Member

I don't think anybody has plans about this, so your contribution would be welcome. But note the standard cov and cor methods should be included in Julia Base (in the sparse module): only the weighted methods are defined in this package. See JuliaLang/julia#7788, which seems to be more limited than what you propose since it only discussed optimizing mean.

BTW, just in case: you should avoid taking inspiration from the glmnet code since it's GPL2 and Julia Base is MIT. Using the same algorithm is fine, though.

@jeffwong
Copy link
Author

jeffwong commented Jul 5, 2017

Ah got it! Thanks again for your help @nalimilan

@nalimilan
Copy link
Member

Closing since the issue should be handled in Base. Feel free to discuss the implementation on that issue.

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

No branches or pull requests

2 participants