[Diagnosismed-list] Segfaults with ROC
Pete Meyer
petemeyer at google.com
Sat Aug 1 00:43:21 CEST 2009
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:
D10X <- function(Xi) {
(1/n) * sum(Y >= Xi[1])
}
D01Y <- function(Yi) {
(1/m) * sum(Yi[1] >= X)
}
The earlier change I suggested does the wrong thing.
Pete
On Fri, Jul 31, 2009 at 3:01 PM, Pete Meyer <petemeyer at google.com> wrote:
> I downloaded DiagnosisMed and have been playing with the ROC function. My
> version info is:
>
> > R.Version()
> $platform
> [1] "x86_64-unknown-linux-gnu"
>
> $arch
> [1] "x86_64"
>
> $os
> [1] "linux-gnu"
>
> $system
> [1] "x86_64, linux-gnu"
>
> $status
> [1] ""
>
> $major
> [1] "2"
>
> $minor
> [1] "9.0"
>
> $year
> [1] "2009"
>
> $month
> [1] "04"
>
> $day
> [1] "17"
>
> $`svn rev`
> [1] "48333"
>
> $language
> [1] "R"
>
> $version.string
> [1] "R version 2.9.0 (2009-04-17)"
>
> I had perhaps a dozen segfaults and otherwise warnings everytime I ran it.
> A typical complaint was:
>
> diagnosismed-list at lists.r-forge.r-project.org *** caught segfault ***
> address 0x100000011, cause 'memory not mapped'
>
> Traceback:
> 1: makeRestartList(...)
> 2: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call),
> msg, call)) .Internal(.dfltWarn(msg, call))}, muffleWarning =
> function() NULL)
> 3: .signalSimpleWarning("longer object length is not a multiple of shorter
> object length", quote(Y >= Xi))
> 4: FUN(X[[204L]], ...)
> 5: lapply(split(X, group), FUN, ...)
> 6: tapply(X, X, "D10X")
> 7: ROC(gold = gold, test = test, Print = Print)
> 8: roc.plot(AC.gold, frm$OldACDiff, label = "AdCreative - Current scale")
>
> I took a look at the code where the problem was occurring:
>
> m <- length(X)
> n <- length(Y)
> D10X <- function(Xi) {
> (1/n) * sum(Y >= Xi)
> }
> D01Y <- function(Yi) {
> (1/m) * sum(Yi >= X)
> }
> VAR.AUC <- sum((tapply(X, X, "D10X") - AUC)^2)/(m * (m -
> 1)) + sum((tapply(Y, Y, "D01Y") - AUC)^2)/(n * (n - 1))
>
> 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:
>
> (1/n) * sum(Y >= rep(Xi, n))
>
> and
>
> (1/m) * sum(rep(Yi, m) >= X)
>
> everything ran just fine. Thought I'd let you know. Thanks for making the
> package available!
>
> Pete
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.r-forge.r-project.org/pipermail/diagnosismed-list/attachments/20090731/541555fc/attachment.htm
More information about the Diagnosismed-list
mailing list