s-news
[Top] [All Lists]

Behavior of cor() with na.methods "omit" and "available"

To: S-News <s-news@wubios.wustl.edu>
Subject: Behavior of cor() with na.methods "omit" and "available"
From: "Kim Elmore" <Kim.Elmore@noaa.gov>
Date: Wed, 09 Nov 2005 10:49:52 -0600
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
I can't quite figure out what the cor() function does with the different na.methods "omit" and "available". I find that each of these methods yields a different answer, even if there is no missing data.

example:
> rn1 <- rnorm(3)
> rn1
[1]  0.52170 -0.34945  0.76141
> rn2 <- rnorm(3)
> rn2
[1]  0.44834 -2.10544 -0.91762
> cor(rn1, rn2)
[1] 0.71767
> cor(rn1, rn2, na.method = "omit")
[1] 0.71767

Which is exactly what I'd expect. But when

> cor(rn1, rn2, na.method = "available")
[1] 0.35884

is the result.

Why is this, when there is no missing data? If there is missing data, the two methods also yield different answers, though "omit" does what I'd expect, which is compute the correlation based on whatever pairs are available. I can't figure out what "available" does. Any insight will be deeply appreciated

Kim Elmore


--
           Kim Elmore, OU/CIMMS/NSSL
  "All of weather is divided into three parts:
Yes, No and Maybe. The greatest of these is Maybe."


<Prev in Thread] Current Thread [Next in Thread>