[R] dist{amap} error??

Radu Dobrin rdobrin at molbio.princeton.edu
Sun Jan 9 20:11:22 CET 2005


Dear all,

I have come across a very confusing matter regarding dist() supplied by 
the amap package:

--- m is just a test matrix

 > library(amap)
Loading required package: mva
Warning message:
package 'mva' has been merged into 'stats'
 > m           a   b   c
aa 0.1 0.2 0.3
bb 2.0 3.0 4.0
cc 2.0 4.0 6.0
dd 0.3 0.2 0.1
 > ds<-dist(m,method="pearson")
 > ds
            aa          bb        cc
bb 7.416666e-03                     cc 1.110223e-16 0.007416666         
dd 2.857143e-01 0.205933333 0.2857143
 > ds<-dist(m,method="correlation")
 > ds
             aa bb cc
bb -4.440892e-16     cc  6.661338e-16  0  dd  2.000000e+00  2  2
 >

Why using method "correlation" I don't get 1-person also person corr 
coef is between (-1,1). Also in help it is said

 >>'pearson': Also named "not centered Pearson" sum(x_i y_i) /[sum(x_i2) 
sum(y_i2)].
 >>'correlation': Also named "Centered Pearson" 1 - corr(x,y).

Maybe corr() is not Pearson correlation ?? Or maybe the data has to be 
scaled? Very confusing. Maybe somebody can help me with this. Also there 
is a sqrt missing in the person corr coef definition.

Best,
Radu

-- 
Dr. Radu Dobrin
Department of Molecular Biology
Princeton University
Washington Road
Princeton, NJ 08544-1014
Phone: 609-258-5657
E-mail: rdobrin at molbio.princeton.edu




More information about the R-help mailing list