JuliaStats / HypothesisTests.jl

Hypothesis tests for Julia
Other
292 stars 87 forks source link

Spearman cor test #304

Open mapi1 opened 12 months ago

mapi1 commented 12 months ago

This PR adds the SpearmanCorrelationTest as suggested in #236. For the confidence interval I took inspiration from this StackExchange thread and used the suggested variance estimator to counter the non-normal distribution of the ranks. Unfortunately, I could not really add meaningful tests for it as R's cor.test does not give the intervals for Spearman correlation and uses another algorithm to calculate the p-value as well. Maybe someone has an idea here or knows a tool that can calculate this already correctly.

codecov-commenter commented 12 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 :tada:

Comparison is base (932eaac) 93.75% compared to head (8869900) 93.81%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #304 +/- ## ========================================== + Coverage 93.75% 93.81% +0.06% ========================================== Files 28 28 Lines 1729 1746 +17 ========================================== + Hits 1621 1638 +17 Misses 108 108 ``` | [Impacted Files](https://app.codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/304?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats) | Coverage Δ | | |---|---|---| | [src/correlation.jl](https://app.codecov.io/gh/JuliaStats/HypothesisTests.jl/pull/304?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaStats#diff-c3JjL2NvcnJlbGF0aW9uLmps) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

mapi1 commented 11 months ago

Thanks for your detailed review! I tried to incorporate it as suggested.

I used the spearmanCI R library to get values for the CIs for testing. They suffer from the same problem as the p value, as they have a low number of matching significant digits. I still wrote the tests as a form of documentation and also added tests to compare against the vales we return to catch feature changes/bugs etc.

Also mention now the ordinal data as it is the main message of the Ruscio paper (Now added to docstring).

3f6a commented 1 month ago

Hello, how is this different from https://github.com/JuliaStats/HypothesisTests.jl/pull/53 ?