Correlation matrices should probably not use `oneunit`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start in src/Statistics.jl at line 652 and inspect how correlation matrices and cor2cov! use oneunit. Reproduce the reported dimensional-data case, then verify that correlation matrices use multiplicative identities on the diagonal and remain dimensionless without breaking the in-place behavior.
Written by the indexing model from the issue text.
Description
Correlation matrices divide each column by the unit, so they are by definition dimensionless. However, the oneunit function is used here.
https://github.com/JuliaStats/Statistics.jl/blob/ad4a0cd12d0abd0a8aed8469a2e71c63ace1773d/src/Statistics.jl#L652
I can't think of an example where this would work. This won't work with Unitful.jl, because the covariance matrix can only have a single unit; if you try to use cor2cov! the type will change, because it has to be unitless.
X = randn(10,3) .*u"m"
julia> cov(X)
3×3 Matrix{Quantity{Float64, 𝐋^2, Unitful.FreeUnits{(m^2,), 𝐋^2, nothing}}}:
1.09164 m^2 0.289683 m^2 -0.139717 m^2
0.289683 m^2 0.481522 m^2 -0.150258 m^2
-0.139717 m^2 -0.150258 m^2 1.2722 m^2
julia> cor(X)
ERROR: DimensionError: m^2 and 0.3995548704289101 are not dimensionally compatible.
I can't see this working for Dates either. The oneunit function should be switched to the one function, because the diagonals of correlation matrices are multiplicative identities. If the return type of one(S[i]) cannot be converted to the element type of the covariance matrix S, there's no way to produce the correlation matrix through in-place modification of S anyway. It's best to just construct a new matrix using the element type of one(S[i]).
- Dominant language
- Julia
- Stars
- 93
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaStats/Statistics.jl
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
JuliaStats/Statistics.jl#221 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
JuliaStats/Statistics.jl#219 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JuliaStats/Statistics.jl#207 · 1 comment ·
-
Difficulty 3/5 Half a day Newbie friendliness 55/100
JuliaStats/Statistics.jl#220 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
JuliaStats/Statistics.jl#215 · 1 reaction ·
All issues in JuliaStats/Statistics.jl
Similar issues
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
path: splitext treats directory references and leading dots as extensionsPossibly taken @Hiten0305l claimed this today. Open
Difficulty 2/5 Half a day Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
JuliaRegistries/RegistryCI.jl#758 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaParallel/Hwloc.jl#93 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100