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 ? -- View this message in context: http://r.789695.n4.nabble.com/qbinom-tp4651460.html Sent from the R help mailing list archive at Nabble.com.
On Fri, Nov 30, 2012 at 9:47 AM, jaybell <stephenn9 at 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
sorry, I repost the question again 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 pa=qbinom(a, 1, 0.5) pb=qbinom(b, 1, 0.5) cor(pa,pb)=-0.8 but when pa=qbinom(a,10,0.5) pb=qbinom(b,10,0.5) cor(pa,pb) becomes -1 again -- View this message in context: http://r.789695.n4.nabble.com/qbinom-tp4651460p4651496.html Sent from the R help mailing list archive at Nabble.com.
On Nov 30, 2012, at 1:05 PM, jaybell wrote:> sorry, I repost the question againWhy? This was already answered.> > 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 > > pa=qbinom(a, 1, 0.5) > pb=qbinom(b, 1, 0.5) > cor(pa,pb)=-0.8 > > but when > pa=qbinom(a,10,0.5) > pb=qbinom(b,10,0.5) > > cor(pa,pb) becomes -1 againWhat part of "plot the values" was difficult to understand?> > -- > View this message in context: http://r.789695.n4.nabble.com/qbinom-tp4651460p4651496.html > Sent from the R help mailing list archive at Nabble.com. >David Winsemius, MD Alameda, CA, USA
On Dec 1, 2012, at 01:00 , David Winsemius wrote:> > On Nov 30, 2012, at 1:05 PM, jaybell wrote: > >> sorry, I repost the question again > > Why? This was already answered. > >> >> 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 >> >> pa=qbinom(a, 1, 0.5) >> pb=qbinom(b, 1, 0.5) >> cor(pa,pb)=-0.8 >> >> but when >> pa=qbinom(a,10,0.5) >> pb=qbinom(b,10,0.5) >> >> cor(pa,pb) becomes -1 again > > What part of "plot the values" was difficult to understand?(Actually, "list the values" might be more informative in this case:> pa[1] 0 0 0 0 0 1 1 1 1> pb[1] 1 1 1 1 0 0 0 0 0 Notice that pb != 1-pa when size=1.) -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com