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

Spearman cor test

Open mapi1 opened this issue 2 years ago • 5 comments

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.

mapi1 avatar Jul 17 '23 13:07 mapi1

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
@@            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 Coverage Δ
src/correlation.jl 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.

codecov-commenter avatar Jul 17 '23 13:07 codecov-commenter

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).

mapi1 avatar Aug 01 '23 11:08 mapi1

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

3f6a avatar Jun 12 '24 11:06 3f6a

@mapi1 thanks for the PR. Do you foresee you'll have the opportunity to move it forward? cheers

dpinol avatar Aug 26 '24 16:08 dpinol

I mentioned a temporary solution in #213.

Forgot to mention that I ignore the confidence interval CorrelationTest gives.

Validated by comparing results from corspearman and SPSS.

AuRobinson avatar Mar 17 '25 07:03 AuRobinson