I'm not very good at statistics, but I know enough to be dangerous. I'm completely new to R, having just discovered it yesterday. Now that the introductions are out of the way ... I have a table with three columns, only two of which are relevant to the discussion: roe0 and roe1. Plotting roe0 against roe1 shows that there is a convincing correlation between them, and is confirmed by the correlation coefficient. So far, so good. What I'd like to do is answer the question: what is the probability that roe1 is above the median (of roe1) given that roe0 is above the median (of roe0). Is there a simple way of doing this in R?
Hi Mark, Try this to get you started: table(roe1 > median(roe1), roe0 > median(roe0)) Hadley On Sun, Jul 4, 2010 at 6:29 AM, Mark Carter <mcturra2000 at yahoo.co.uk> wrote:> I'm not very good at statistics, but I know enough to be dangerous. I'm completely new to R, having just discovered it yesterday. Now that the introductions are out of the way ... > > I have a table with three columns, only two of which are relevant to the discussion: roe0 and roe1. Plotting roe0 against roe1 shows that there is a convincing correlation between them, and is confirmed by the correlation coefficient. So far, so good. What I'd like to do is answer the question: what is the probability that roe1 is above the median (of roe1) given that roe0 is above the median (of roe0). Is there a simple way of doing this in R? > > > > > > ______________________________________________ > 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. >-- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
On 2010-07-04 5:29, Mark Carter wrote:> I'm not very good at statistics, but I know enough to be dangerous. I'm completely new to R, having just discovered it yesterday. Now that the introductions are out of the way ... > > I have a table with three columns, only two of which are relevant to the discussion: roe0 and roe1. Plotting roe0 against roe1 shows that there is a convincing correlation between them, and is confirmed by the correlation coefficient. So far, so good. What I'd like to do is answer the question: what is the probability that roe1 is above the median (of roe1) given that roe0 is above the median (of roe0). Is there a simple way of doing this in R? >It might be dangerous to just give the answer, so I'll provide a hint: Since you know how to plot the data: plot(roe1, roe0) abline(v = median(roe1), h = median(roe0)) Now start counting points in the relevant quadrants. Getting R to count the points is left as an exercise (which should be easy after working through An Introduction to R). -Peter Ehlers