Re: A problem with the Spearman rank correlation function (spcorr)

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sun Feb 20 2011 - 14:05:09 MST

x = asciiread("data_Cabauw_MERRA_wspd-iqrln_full1.dat",-1,"float")
y = asciiread("data_Cabauw_MERRA_wspd-iqrln_hist_wspd-iqrln12-1.dat",-1,
r = spcorr(x,y) ; r = 0.6188006 ; r*r=0.3829142

Just for 'fun', I also tried

i = ind( .not.(x.eq.0 .and. y.eq.0) )
R = spcorr(x(i),y(i)) ; R = 0.3943804 ; R*R = 0.1555359
====

I speculate it must have something to do with the
many ties [ x(n)=y(n)=0 ]. There is nothing in
the fortran code to indicate ties are an issue.

====
The R code shows no rank correlation. Is that what you expect?

On 2/18/11 1:48 PM, Emilie Vanvyve wrote:
> Hello,
>
> I ran into another issue with the Spearman rank correlation (NCL
> function spcorr).
>
> I compare two ASCII files which each contains 1 column of 1085 values
> (see attached). I read them in, give the data to spcorr and obtain a
> value of the Spearman correlation that differs from that computed with R
> (independently on the same files). This has been confirmed by another
> person who used NCL on another computer and got the same results using
> these files. I use NCL 5.2.0 on a Linux cluster and he uses NCL 5.2.1 on
> a Mac OS workstation. We also both computed the Pearson correlation
> (with escorc in NCL) and obtain the correct values, i.e. they match the
> Pearson correlation as calculated by R.
>
> Here are the values we obtain (note that this is the square of spcorr):
> - NCL value: 0.382914,
> - R value: 0.005104339.
>
> I would really appreciate if anyone could confirm/infirm this. I guess
> we're wrong (again), but I just can't figure out where. This time, the
> arrays have no missing values, just plenty of 0 and some non-zero values.
>
> Emilie
>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Feb 20 14:05:13 2011

This archive was generated by hypermail 2.1.8 : Wed Feb 23 2011 - 16:47:57 MST