[R] cor, cov, method "pairwise.complete.obs"

Eric Lecoutre lecoutre at stat.ucl.ac.be
Fri Oct 22 12:39:04 CEST 2004


Hi UseRs,

I don't want to die beeing idiot...

I dont understand the different results between:
cor() and cov2cov(cov()).

See this little example:

 > x=matrix(c(0.5,0.2,0.3,0.1,0.4,NA,0.7,0.2,0.6,0.1,0.4,0.9),ncol=3)
 > cov2cor(cov(x,use="pairwise.complete.obs"))
            [,1]       [,2]       [,3]
[1,]  1.0000000  0.4653400 -0.1159542
[2,]  0.4653400  1.0000000 -0.7278728
[3,] -0.1159542 -0.7278728  1.0000000
 > cor(x,use="pairwise.complete.obs")
            [,1]       [,2]       [,3]
[1,]  1.0000000  0.3973597 -0.1159542
[2,]  0.3973597  1.0000000 -0.9736842
[3,] -0.1159542 -0.9736842  1.0000000


My question arises in a context where cor(mydata, 
use="pairwise.complete.obs")  returns correlations on diagonal that are 
near 0.95 (where as my data do have 100 observations and only 12 missing 
values...).

Do cor() and cov() handle the same way the argument "pairwise.complete.obs"?

Eric

  R.version
          _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    0.0
year     2004
month    10
day      04
language R


Eric Lecoutre
UCL /  Institut de Statistique
Voie du Roman Pays, 20
1348 Louvain-la-Neuve
Belgium

tel: (+32)(0)10473050
lecoutre at stat.ucl.ac.be
http://www.stat.ucl.ac.be/ISpersonnel/lecoutre

If the statistics are boring, then you've got the wrong numbers. -Edward 
Tufte




More information about the R-help mailing list