Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201867

cor and cov2cor different results with use = pairwise.complete.obs

$
0
0

Running:

cor(x, use = "pairwise.complete.obs")`

vs running

c <- cov(x, use = "pairwise.complete.obs")
cov2cor(c)

give different results. Anyone know why and which one gives correct results? Both functions call C++ code which I haven't figured out how to parse.

Reproducible data:

x <- data.frame(a1 = rnorm(10), a2 = rnorm(10), a3 = rnorm(10))
x$a1[c(1,3)] <- NA

c <- cov(x, use = "pairwise.complete.obs")
cov2cor(c)
cor(x, use = "pairwise.complete.obs")

Viewing all articles
Browse latest Browse all 201867

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>