In looking at this again, it seems that what you want to do is add up how many Y's are greater than each distinct Xi value and vice versa. There are multiple observations with the same value, so the Xi's that were getting passed were sometimes of length greater than 1 and R was complaining that the length of Y was not a multiple of Xi (which is a good thing). It looks the the following change to the function produces the right result:<br>
<br> D10X <- function(Xi) {<br> (1/n) * sum(Y >= Xi[1])<br> }<br> D01Y <- function(Yi) {<br> (1/m) * sum(Yi[1] >= X)<br> }<br><br>The earlier change I suggested does the wrong thing.<br>
<br>Pete<br><br><div class="gmail_quote">On Fri, Jul 31, 2009 at 3:01 PM, Pete Meyer <span dir="ltr"><<a href="mailto:petemeyer@google.com">petemeyer@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I downloaded DiagnosisMed and have been playing with the ROC function. My version info is:<br><br><div style="margin-left: 40px;">> R.Version()<br>$platform<br>[1] "x86_64-unknown-linux-gnu"<br><br>$arch<br>
[1] "x86_64"<br>
<br>$os<br>[1] "linux-gnu"<br><br>$system<br>[1] "x86_64, linux-gnu"<br><br>$status<br>[1] ""<br><br>$major<br>[1] "2"<br><br>$minor<br>[1] "9.0"<br><br>$year<br>[1] "2009"<br>
<br>$month<br>[1] "04"<br><br>$day<br>[1] "17"<br><br>$`svn rev`<br>[1] "48333"<br><br>$language<br>[1] "R"<br><br>$version.string<br>[1] "R version 2.9.0 (2009-04-17)"<br>
</div><br>I had perhaps a dozen segfaults and otherwise warnings everytime I ran it. A typical complaint was:<br><br><div style="margin-left: 40px;"><a href="mailto:diagnosismed-list@lists.r-forge.r-project.org" target="_blank">diagnosismed-list@lists.r-forge.r-project.org</a> *** caught segfault ***<br>
address 0x100000011, cause 'memory not mapped'<br><br>Traceback:<br> 1: makeRestartList(...)<br> 2: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call))}, muffleWarning = function() NULL)<br>
3: .signalSimpleWarning("longer object length is not a multiple of shorter object length", quote(Y >= Xi))<br> 4: FUN(X[[204L]], ...)<br> 5: lapply(split(X, group), FUN, ...)<br> 6: tapply(X, X, "D10X")<br>
7: ROC(gold = gold, test = test, Print = Print)<br> 8: roc.plot(AC.gold, frm$OldACDiff, label = "AdCreative - Current scale")<br></div><br>I took a look at the code where the problem was occurring:<br><br><div style="margin-left: 40px;">
m <- length(X)<br> n <- length(Y)<br> D10X <- function(Xi) {<br> (1/n) * sum(Y >= Xi)<br> }<br> D01Y <- function(Yi) {<br> (1/m) * sum(Yi >= X)<br> }<br> VAR.AUC <- sum((tapply(X, X, "D10X") - AUC)^2)/(m * (m - <br>
1)) + sum((tapply(Y, Y, "D01Y") - AUC)^2)/(n * (n - 1))<br></div><br>It looks like the code should run, expanding the Yi to rep(Yi, m) and likewise for Xi. When I explicitly replaced those two statements with:<br>
<br> (1/n) * sum(Y >= rep(Xi, n))<br>
<br>and<br><br> (1/m) * sum(rep(Yi, m) >= X)<br>
<br>
everything ran just fine. Thought I'd let you know. Thanks for making the package available!<br><font color="#888888"><br>Pete<br>
</font></blockquote></div><br>