Skip to content

ENH: cov and matrix tools to work with covariances and correlations - rebased - #6696

Open
josef-pkt wants to merge 3 commits into
statsmodels:mainfrom
josef-pkt:cov_matrix_tools_rebased
Open

josef-pkt wants to merge 3 commits into
statsmodels:mainfrom
josef-pkt:cov_matrix_tools_rebased

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

rebased version of #4143

@pep8speaks

pep8speaks commented May 8, 2020 •

Copy link
Copy Markdown

Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 148:5: E741 ambiguous variable name 'l'
Line 166:5: E741 ambiguous variable name 'l'

Line 25:1: F401 'statsmodels.stats._cov_tools._cov_corr' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools._cov_cov' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools._cov_cov_mom4' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools._cov_cov_vech' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools._gls_cov_vech' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools._mom4_normal' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.cov_corr_coef_normal' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.cov_cov_data' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.cov_cov_fisherz' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.mom4' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.ravel_indices' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.unvech' imported but unused
Line 25:1: F401 'statsmodels.stats._cov_tools.vech_cross_product' imported but unused

Comment last updated at 2020-05-08 19:09:48 UTC

@coveralls

coveralls commented May 8, 2020 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.04%) to 87.743% when pulling 8ad7f16 on josef-pkt:cov_matrix_tools_rebased into eda1c08 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member Author

unit test coverage 58% https://coveralls.io/builds/30661699/source?filename=statsmodels%2Fstats%2F_cov_tools.py
needs work

some functions like cov_corr have test coverage and could be used almost directly.

It would be good to have some hypothesis test or confidence interval functions for all elements of a cov or corr matrix as usecases that can be merged.
I leave this PR until I'm working on those inference problems.

@josef-pkt

josef-pkt commented May 8, 2020 •

Copy link
Copy Markdown
Member Author

http://personality-project.org/r/psych/help/r.test.html
has tests for correlation coefficients citing Steiger

There is also rcorr in Hmisc packag
and a pcor.test (and spcor.test) for partial (and semipartial) correlation in package ppcor which I looked at for the "multicollinearity" PR

It looks like all the above r test statistics/pvalues are only for the null of zero correlation.

My guess is that those are element wise pvalues, similar to pvalues from t_test in our Results classes.
psych r.test adds standard p-value corrections.

Using Neudecker and functions in this PR, we have the covariance of the cov or corr estimates, so we can also do joint hypothesis and hypothesis on linear combination of correlation coefficients.

In many of the applications in psych and similar this might still work because number of variables doesn't become large.
k = 50
(k * (k - 1) / 2)**2 = 1500625.0

However, the matrix size grows very fast (k**4), and we might be able to work only element wise or using special structures.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants