[R] Named numeric vectors with the same value but different names return different results when used as thresholds for calculating true positives

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Tue Jul 12 11:09:30 CEST 2011


Hi,

Am 11.07.2011 22:57, schrieb Lyndon Estes:
> ctch[ctch$threshold == 3.5, ]
> # [1] threshold val       tp        fp        tn        fn        tpr
>      fpr       tnr       fnr
> #<0 rows> (or 0-length row.names)

this is the very effective FAQ 7.31 trap.
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

Welcome to the first circle of Patrick Burns' R Inferno!

Also, unname() is a more intuitive way of removing names.

And I think your code is quite inefficient, because you calculate
quantiles many times, which involves repeated ordering of x, and you may
use a inefficient size of bin (either to small and therefore calculating
the same split many times or to large and then missing some splits).
I'm a bit puzzled what is x and y in your code, so any further advise is
vague but you might have a look at any package that calculates
ROC-curves such as ROCR or pROC (and many more).

Hth

-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790



More information about the R-help mailing list