I would much appreciate if?someone would enlighten me on how to calculate a distance matrix based on correlation coefficient (Spearman)? The simple correlation matrix seems not to work. I am trying to use it?in FSO/MFSO to calculate the influence of climate?factors?on?heavy metals?concentrations. Cheers, Dragos Zaharescu ?? Animal Anatomy Lab Faculty of Biological Sciences Vigo University, apd. 137 36310, Vigo, SPAIN zaha_dragos at yahoo.com zdragos at uvigo.es http://webs.uvigo.es/zdragos/ ? ~ You should be the change you want to see in the world?~ Ghandi
Distance matrix based on correlation coefficient
4 messages · Dragos Zaharescu, Jari Oksanen, Gavin Simpson
On Tue, 2010-07-20 at 12:12 -0700, Dragos Zaharescu wrote:
I would much appreciate if someone would enlighten me on how to calculate a distance matrix based on correlation coefficient (Spearman)? The simple correlation matrix seems not to work.
In what sense did it not work? We aren't mind readers! Hence the posting guide asking you to provide information that will help us to help you.
I am trying to use it in FSO/MFSO to calculate the influence of climate factors on heavy metals concentrations.
Does this help at all?
dat <- data.frame(A = rnorm(10), B = rnorm(10), C = rnorm(10)) cor(dat)
A B C A 1.00000000 0.08986947 0.1224007 B 0.08986947 1.00000000 0.2667838 C 0.12240068 0.26678381 1.0000000
1 - cor(dat) ## dissimilarity
A B C A 0.0000000 0.9101305 0.8775993 B 0.9101305 0.0000000 0.7332162 C 0.8775993 0.7332162 0.0000000
as.dist(1 - cor(dat))
A B B 0.9101305 C 0.8775993 0.7332162 HTH G
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
On 20/07/10 22:42 PM, "Gavin Simpson" <gavin.simpson at ucl.ac.uk> wrote:
On Tue, 2010-07-20 at 12:12 -0700, Dragos Zaharescu wrote:
I would much appreciate if someone would enlighten me on how to calculate a distance matrix based on correlation coefficient (Spearman)? The simple correlation matrix seems not to work.
1 - cor(dat) ## dissimilarity
Actually the canonical transformation to distance is sqrt(2-2*cor(dat)). Cheers, Jari Oksanen
On Tue, 2010-07-20 at 23:35 +0300, Jari Oksanen wrote:
On 20/07/10 22:42 PM, "Gavin Simpson" <gavin.simpson at ucl.ac.uk> wrote:
On Tue, 2010-07-20 at 12:12 -0700, Dragos Zaharescu wrote:
I would much appreciate if someone would enlighten me on how to calculate a distance matrix based on correlation coefficient (Spearman)? The simple correlation matrix seems not to work.
1 - cor(dat) ## dissimilarity
Actually the canonical transformation to distance is sqrt(2-2*cor(dat)). Cheers, Jari Oksanen
Of course, thanks Jari. That 1 - bit was total rubbish, not even acknowledging that cor could be negative. Not sure what came over me; I blame the heat here in London ;-) Hangs head in shame. G
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%