Re: [R] cor and missing values. Bug?

About this list Date view Thread view Subject view Author view Attachment view

From: Robert W. Baer, Ph.D. (rbaer@atsu.edu)
Date: Wed 26 May 2004 - 23:43:56 EST


Message-id: <001001c4432b$dffbeaa0$2e80010a@BigBaer>


> Not to put too fine a point on it, but did you consider checking the
> NEWS file for the most recent version (1.9.0,
> http://cran.r-project.org/src/base/NEWS)?
>
> o The cor() function did not remove missing values in the
> non-Pearson case.

There is still something a little strange in version 1.9.0. What is the
source of the discrpancy between cor() and cor.test()?

> vec1 <- 1:10
> vec2 <- 2*vec1
> vec1[c(1, 5)] <- NA
> cor(vec1[-c(1,5)], vec2[-c(1,5)], use="pair", method="spearman")
[1] 1
> cor(vec1, vec2, use="complete", method="spearman")
[1] 0.99544
> cor.test(vec1, vec2, use="complete", method="spearman")

        Spearman's rank correlation rho

data: vec1 and vec2
S = 0, p-value = 4.96e-05
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
  1

Rob Baer

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:12 EST