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

Point to cov if not positive definite #746

Merged
merged 4 commits into from
Dec 20, 2021

Conversation

rikhuijzer
Copy link
Contributor

@rikhuijzer rikhuijzer commented Dec 8, 2021

I was trying to calculate the Cronbach alpha for my dataset but got a Covariance matrix must be positive definite. error. Assuming that something was wrong with my data, I gave up and went to R's psych package only to figure out that the calculation worked there.

I asked @storopoli, and it turned out that I should use cronbachalpha(cov(Matrix(...))) which is indeed in the documentation, but well, also easy to miss... This PR makes it harder to miss the fact that you should pass a covariance matrix.

@storopoli
Copy link
Contributor

storopoli commented Dec 8, 2021

I can review the PR if no maintainer is available.

Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be interesting to add some tests to test/reliability.jl.

@rikhuijzer
Copy link
Contributor Author

Might be interesting to add some tests to test/reliability.jl.

I would say it's already mostly covered by

# testing when Matrix is not positive-definite
cov_not_pos = [-1 1;
-1 1]
@test_throws ArgumentError cronbachalpha(cov_not_pos)

@rikhuijzer
Copy link
Contributor Author

bump @nalimilan @andreasnoack.

Could one of you take a quick look and merge or give feedback? This PR is a non-breaking and easily reversible change which may help users a lot.

src/reliability.jl Outdated Show resolved Hide resolved
rikhuijzer and others added 3 commits December 19, 2021 17:51
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
@rikhuijzer
Copy link
Contributor Author

Thanks for fixing the typo. In abf4b88, I updated the indentation because there were 9 spaces instead of 8.

@nalimilan nalimilan merged commit 4baf521 into JuliaStats:master Dec 20, 2021
@nalimilan
Copy link
Member

Thanks!

kagalenko-m-b pushed a commit to kagalenko-m-b/StatsBase.jl that referenced this pull request Dec 24, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants