StatsBase.jl icon indicating copy to clipboard operation
StatsBase.jl copied to clipboard

Allow computing the correlation matrix from the covariance matrix only

Open ASaragga opened this issue 4 years ago • 5 comments

Following issue #652 in StatsBase.jl

ASaragga avatar Feb 16 '21 16:02 ASaragga

Can you add tests?

nalimilan avatar Feb 16 '21 20:02 nalimilan

Did you remove the tests on purpose?

nalimilan avatar Feb 23 '21 08:02 nalimilan

Well, which tests? I didn’t add any tests to Statistics.jl yet. There where two tests that I added to StatsBase.jl in my PR, that failed for what are now obvious reasons.

On 23 Feb 2021, at 08:50, Milan Bouchet-Valat [email protected] wrote:

Did you remove the tests on purpose?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JuliaStats/StatsBase.jl/pull/661#issuecomment-784012184, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJ5RCGRNYNRAPBFCV36FM3TANT3XANCNFSM4XWXW22A.

ASaragga avatar Feb 23 '21 15:02 ASaragga

Hi there,

Looks like the method hasn't been implemented. I can't edit this PR. Can someone add the following code? (and is it sufficient?) Alternatively should I submit a separate PR?

In src/cov.jl

cov2cor!(C) = cov2cor!(C, [sqrt(C[i,i]) for i = 1:size(C, 1)])
cov2cor(C) = cov2cor!(copy(C))

In test/cov.jl

# Around line 126
@test cov2cor(cov1) ≈ cor1
@test cov2cor(cov2) ≈ cor2

# Around line 202
@test cov2cor(cov1) ≈ cor1
@test cov2cor(cov2) ≈ cor2

# Around line 209
StatsBase.cov2cor!(tmp_cov1)
@test tmp_cov1 ≈ cor1

# Around line 214
StatsBase.cov2cor!(tmp_cov2)
@test tmp_cov2 ≈ cor2

JockLawrie avatar Jan 18 '22 02:01 JockLawrie

Please make a new PR, that's simpler.

nalimilan avatar Jan 18 '22 09:01 nalimilan

Superseded by https://github.com/JuliaStats/StatsBase.jl/pull/816

andreasnoack avatar May 03 '24 10:05 andreasnoack