[R] rank analysis - reinventing the wheel?

Frank Harrell f.harrell at vanderbilt.edu
Sun Aug 21 21:01:17 CEST 2011


This is close: require(Hmisc); ?xYplot and see method='quantile'
Frank

Ben qant wrote:
> 
> Hello,
> 
> I have two data frames. One is my dependent variable and the other is my
> independent variable. For each row I'd like to split the independent
> variable into fractiles (25 or more) and calculate the average value of
> the
> dependent variable. Then I would like to plot the average of the averages
> for each row for each fractile.  If possible, I'd like to have the option
> to
> 1) define the fractiles independently for each row, and 2) define the
> fractiles based off the independent variable data frame as a whole at the
> start and keep it fixed.
> 
> Anyway, is there a pacakge/function in R that does something like this so
> I
> don't have to reinvent the wheel? If not, any help on how to do this
> efficiently in R would be great.
> 
> Here is a super simple example using 3 fractiles:
> 
> independent data frame:
>   item1 item2 item3
> 1    18    15    16
> 2    12    12    17
> 3    20    13    18
> 
> dependent data frame:
>   item1 item2 item3
> 1     3     1     6
> 2     2     2     7
> 3     1     3     8
> 
> fractiles by row by item: (done with independent data frame, redefining
> fractiles each row)
> fractiles:  1                    2       3
> row 1    item2             item3   item1  (because 15 < 16 < 18)
> row 2    item1,item2    [none]  item3  (because 12 < 17 ... or however
> ties
> are handled is fine)
> row 3    item2             item3   item1  (because 13 < 18 < 20)
> 
> Note: in the above fractiles there would almost always be more than one
> item
> in each fractile if this example wasn't so simple...
> 
> dependent variable averages by row by fractile:
> fractiles:  1                    2       3
> row 1       1                   6        3
> row 2       2               [none]     7
> row 3       3                   8         1
> 
> Note: obviously this example is so simple there aren't actual averages
> because there aren't enough items for each fractile, but I hope you get
> the
> point.
> 
> So then the averages of the fractiles would be:
> fractiles:                               1                    2       3
> dependent data avg:               2                   7        3.67
> 
> Then I would like to plot a histogram of the fractile averages directly
> above.
> 
> Thanks!
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 


-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/rank-analysis-reinventing-the-wheel-tp3758729p3758906.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list