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

Inconsistencies in cor calculation #63

Open
bkamins opened this issue Jan 3, 2021 · 2 comments
Open

Inconsistencies in cor calculation #63

bkamins opened this issue Jan 3, 2021 · 2 comments
Labels

Comments

@bkamins
Copy link
Contributor

bkamins commented Jan 3, 2021

Here are some cor corner cases that would be good to fix by 2.0 release of Julia:

julia> cor(Union{Float64, Missing}[missing]) # this is the expected result
1.0

julia> cor([missing])
missing

julia> cor(Any[missing])
ERROR: MethodError: no method matching zero(::Type{Any})

julia> cor(Any[1])
ERROR: MethodError: no method matching zero(::Type{Any})

EDIT: this is based on the assumption that if someone wants cor and has missing this missing represents a number (and not e.g. a string)

@PGS62
Copy link

PGS62 commented Feb 17, 2024

Here is another edge case (with Statistics1,10.0 and Julia 1.10)

julia> cor(fill(missing,2,2))
ERROR: MethodError: no method matching copy(::Missing)

julia> cor(fill(missing,3,3))
ERROR: MethodError: no method matching copy(::Missing)

julia> cor(fill(missing,4,4)) #this is the expected result
4×4 Matrix{Missing}:
 missing  missing  missing  missing
 missing  missing  missing  missing
 missing  missing  missing  missing
 missing  missing  missing  missing

@mbauman
Copy link
Contributor

mbauman commented Aug 27, 2024

julia> cor(fill(missing,4,4)) #this is the expected result
4×4 Matrix{Missing}:
 missing  missing  missing  missing
 missing  missing  missing  missing
 missing  missing  missing  missing
 missing  missing  missing  missing

Is that the expected result? Or should it be akin to the NaN:

julia> cor(fill(NaN,4,4))
4×4 Matrix{Float64}:
   1.0  NaN    NaN    NaN
 NaN      1.0  NaN    NaN
 NaN    NaN      1.0  NaN
 NaN    NaN    NaN      1.0

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

No branches or pull requests

4 participants