title: Replicate R and matlab results in finding the optimal threshold from ROC curve
body: <p>I am using the <code>OptimalCutpoints</code> package in <code>R</code> to find the optimal cutoff point from ROC curve. The criterion for finding the optimal threshold is maximizing Youden's index:  </p>
  
  <pre><code>J = sensitivity + specificity - 1  
  </code></pre>
  
  <p>I am trying to do the same in matlab with the function <code>perfcurve</code>. I run <code>perfcurve</code> with the default criteria for two axis, the FPR in x-coordinates and TPR in y-coordinates. The <code>perfcurve</code> returns a matrix with thresholds and chooses one of them according to the criteria.<br>
  The problem is that the optimal threshold that matlab gives, is not the same as in R. However, the optimal threshold according to R is included in the threshold matrix that matlab returns.</p>
  
  <p>How can I replicate the results that R returns with the ones in matlab? I am suspecting that the criteria are not correctly set in matlab for Youden's index.    </p>