On Fri, Nov 30, 2012 at 9:47 AM, jaybell <stephe...@yahoo.com.tw> wrote:
> a=c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9)
> b=c(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1)
> cor(a,b)= -1
>
> a'=qbinom(a, 1, 0.5)
> b'=qbinom(b, 1, 0.5)
> why cor(a',b') becomes -0.5 ?

On my computer the correlation is -0.8. It is not 1 because you did a
non-linear transformation of a and b. Plot a vs. b, then plot a' vs b'
and you will see why the correlation is not -1: a vs b is  a straight
line, a' vs b' is not a straight line.

Peter

______________________________________________
R-help@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.

Reply via email to