Computes Spearman rank correlation coefficient between x and y.
Uses f_sts_pcc_core
on ranks.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x(:) |
x vector (assumed size array) |
||
real(kind=wp), | intent(in) | :: | y(:) |
y vector (assumed size array) |
Spearman correlation coefficient
pure function f_sts_scc_core(x, y) result(corr) ! ==== Description !! Computes Spearman rank correlation coefficient between x and y. !! Uses `f_sts_pcc_core` on ranks. ! ==== Declarations real(wp), intent(in) :: x(:) !! x vector (assumed size array) real(wp), intent(in) :: y(:) !! y vector (assumed size array) real(wp) :: corr !! Spearman correlation coefficient real(wp), allocatable :: rx(:) !! ranks of x real(wp), allocatable :: ry(:) !! ranks of y ! ==== Instructions ! rank both arrays (uses your existing s_utl_rank) ! rank arrays allocated in ranking call s_utl_rank(x, rx) call s_utl_rank(y, ry) ! Pearson correlation on ranks corr = f_sts_pcc_core(rx, ry) ! deallocate deallocate(rx) deallocate(ry) end function f_sts_scc_core