I've been asked about how to get a bunch of Spearman correlations in
matrix form. This can be done using the npcorr() function. Here's an
example.

<hansl>
function matrix spearman_mat (list L)
   matrix SC = {}
   strings rnames = array(0)
   n = nelem(L)
   loop i=1..n
      loop j=1..i-1
           SC |= npcorr(L[j], L[i], spearman)
           rnames += sprintf("%s_%s", varname(L[j]), varname(L[i]))
      endloop
   endloop
   cnameset(SC, defarray("spearman", "t-stat", "p-value"))
   rnameset(SC, rnames)
   return SC
end function

open data4-10
list L = dataset
matrix SC = spearman_mat(L)
print SC
</hansl>

Allin Cottrell
_______________________________________________
Gretl-users mailing list -- gretl-users@gretlml.univpm.it
To unsubscribe send an email to gretl-users-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/

Reply via email to