[R] robust method to obtain a correlation coeff?

Martin Maechler maechler at stat.math.ethz.ch
Tue Aug 25 12:11:44 CEST 2009


>>>>> "JK" == John Kane <jrkrideau at yahoo.ca>
>>>>>     on Mon, 24 Aug 2009 10:01:56 -0700 (PDT) writes:

    JK> I may be misunderstanding the question but would cor(d1,
    JK> use='complete.obs') or some other variant of "use" help?

Yes!  I've been a bit appalled to read that nobody else gave
this (in my view  *the correct* !) answer.

Leaving away NA's via na.omit() or similar is more general, but
for cor() definitely less flexible!

Martin Maechler, ETH Zurich


    JK> --- On Mon, 8/24/09, Christian Meesters
    JK> <meesters at imbie.uni-bonn.de> wrote:

    >> From: Christian Meesters <meesters at imbie.uni-bonn.de>
    >> Subject: [R] robust method to obtain a correlation coeff?
    >> To: "r-help at r-project.org Help" <r-help at r-project.org>
    >> Received: Monday, August 24, 2009, 10:47 AM Hi,
    >> 
    >> Being a R-newbie I am wondering how to calculate a
    >> correlation coefficient (preferably with an associated
    >> p-value) for data like:
    >> 
    >> > d[,1] [1] 25.5 25.3 25.1   NA 23.3 21.5 23.8 23.2 24.2
    >> 22.7 27.6 24.2 ...  > d[,2] [1]  0.0 11.1  0.0   NA  0.0
    >> 10.1 10.6  9.5  0.0 57.9  0.0  0.0  ...
    >> 
    >> Apparently corr(d) from the boot-library fails with NAs
    >> in the data, also cor.test cannot cope with a different
    >> number of NAs.  Is there a solution to this problem
    >> (calculating a correlation coefficient and ignoring
    >> different number of NAs), e.g. Pearson's corr coeff?
    >> 
    >> If so, please point me to the relevant piece of
    >> documentation.
    >> 
    >> TIA Christian
    >> 
    >> ______________________________________________
    >> R-help at r-project.org mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
    >> read the posting guide
    >> http://www.R-project.org/posting-guide.html and provide
    >> commented, minimal, self-contained, reproducible code.
    >> 


      __________________________________________________________________
    JK> Be smarter than spam. See how smart SpamGuard is ons in
    JK> Mail and switch to New Mail today or register for free
    JK> at http://mail.yahoo.ca

    JK> ______________________________________________
    JK> R-help at r-project.org mailing list
    JK> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do
    JK> read the posting guide
    JK> http://www.R-project.org/posting-guide.html and provide
    JK> commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list