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

Frank Harrell f.harrell at vanderbilt.edu
Tue Jul 12 13:56:23 CEST 2011


Also note that the statistical method you are using does not seem in line
with decision theory, and you are assuming that the threshold actually
exists.  It is seldom the case that the relationship of a predictor with the
response is flat on at least one side of the threshold.  A smooth prediction
model may be in order.
Frank

Eik Vettorazzi wrote:
> 
> 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
> 
> ______________________________________________
> 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/Named-numeric-vectors-with-the-same-value-but-different-names-return-different-results-when-used-as-s-tp3660833p3662030.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list