Programming the statistical procedures from SAS

ROC in SAS- obtaining a cut-off value

Reply
Regular Contributor
Posts: 173

ROC in SAS- obtaining a cut-off value

Hi there,

I am interested in finding a cut-off value of a continuous variable in my dataset.

Has anyone performed ROC analyses in SAS to obtain a cut-off value.

After trying some variation in SAS code, I got the attached results, but I am not quite sure about how to interprete the results.

It would be helpful if you could help me with the code to obtain the criterion/cut-off value and the area under the curve.Is there any straihforward simple code/way to do this in SAS?

Below is the SAS code I tried:

ods graphics on;

   proc logistic data=diabet.data plots(only)=(roc(id=obs) effect) descending;

model cadcat2=eatcm / scale=none

                            clparm=wald

                            clodds=pl

                            rsquare;

   run;

   ods graphics off;/

I tried SPSS too, but for some reason i kept getting the following warning: 

Text: 0,1 Command: ROC

An invalid numeric field has been found.  The result has been set to the system-missing value.

Execution of this command stops.

Any help would be greatly appreciated.

Thank you very much!

Ashwini

SAS Employee
Posts: 187

Re: ROC in SAS- obtaining a cut-off value

Choosing a cutpoint depends on what criterion you want to use.  The best tool for this is the CTABLE option in the MODEL statement. This option displays a table with statistics for each of a range of cutpoints such as the correct classification rate, false positive and negative rates, etc.  If you want, you can change the cutpoints used in the table with the PPROB= option.  For example, with this table you could find the cutpoint that maximizes the correct classification rate, or the cutpoint that satisfies your criteria for false positive and false negative rates.

Regular Contributor
Posts: 173

Re: ROC in SAS- obtaining a cut-off value

This is helpful. But I wonder how would I know the cut-point value of that continuous variable and the are under the curve.

Can i find that using any other option in the SAS code?

Valued Guide
Valued Guide
Posts: 673

Re: ROC in SAS- obtaining a cut-off value

You have to make a judgement about the relative importance for false positives and false negatives. Which are more costly to make? IF they are equally costly, then you can use Youden's J statistic = sensitivity + specificty -1 = true positive proportion + true negative proportion -1. Use the cutoff that gives the highest J. The necessary values are in the ctable that statdave told you about.

Valued Guide
Valued Guide
Posts: 673

Re: ROC in SAS- obtaining a cut-off value

...and the area under the ROC curve is estimated with the c statistic that is found in the Association of Predict.... table in the output. Also, you should check out the ROC statement in the help file for more ROC related output.

Regular Contributor
Posts: 173

Re: ROC in SAS- obtaining a cut-off value

Thanks for the response! I did calculate the Youden's J statistics but I am not sure how to find out the corresponding cut-off value of the "interest variable- EATCM" Below I am pasting the part of the SAS output and the last column is the Youden's J stat and the first column is the probability. The max value of Youden's J is 154.6 and it corresponds to the 0.12 probability. From this information, how would I know the cut-off value of the interest variable?

Classification Table
ProbCorrectIncorrectPercentages
LevelEventNon-EventNon-CorrectSensi-Speci-FALSEFALSE
EventEventtivityficityPOSNEGJ
033032809.1100090.9.99
0.023362266026.310018.9890117.9
0.0431162166253.593.949.484.31.2142.3
0.0626209119765.178.863.782.13.2141.5
0.082623692772.678.872782.9149.8
0.12525474877.375.877.474.73.1152.2
0.12242725698272.782.9703.2154.6
0.1420280481383.160.685.470.64.4145
0.1617285431683.751.586.971.75.3137.4
0.181629137178548.588.769.85.5136.2
0.216301271787.848.591.862.85.3139.3
0.2214304241988.142.492.763.25.9134.1
0.2412306222188.136.493.364.76.4128.7
0.2610307212387.830.393.667.77122.9
0.289309192488.127.394.267.97.2120.5
0.39314142489.527.395.760.97.1122
0.328318102590.324.29755.67.3120.2
0.34432082989.812.197.666.78.3108.7
0.36432082989.812.197.666.78.3108.7
0.38432082989.812.197.666.78.3108.7
0.443217299012.197.963.68.3109
0.42332353090.39.198.562.58.5106.6
0.442323531906.198.571.48.8103.6
0.462323531906.198.571.48.8103.6
0.482323531906.198.571.48.8103.6
0.5232443190.36.198.866.78.7103.9
0.52232533190.66.199.1608.7104.2
0.54232533190.66.199.1608.7104.2
0.56232533190.66.199.1608.7104.2
0.58132533290.3399.1759101.1
0.6132623290.6399.466.78.9101.4
0.62132623290.6399.466.78.9101.4
0.64132623290.6399.466.78.9101.4
0.66032623390.3099.41009.298.4
0.68032623390.3099.41009.298.4
0.7032623390.3099.41009.298.4
0.72032623390.3099.41009.298.4
0.74032713390.6099.71009.298.7
0.76032713390.6099.71009.298.7
0.78032713390.6099.71009.298.7
0.8032713390.6099.71009.298.7
0.82032713390.6099.71009.298.7
0.84032713390.6099.71009.298.7
0.86032713390.6099.71009.298.7
0.88032713390.6099.71009.298.7
0.9032803390.90100.9.199
Valued Guide
Valued Guide
Posts: 673

Re: ROC in SAS- obtaining a cut-off value

First of all, the formula is true positive PROPORTION + true negative PROPORTION -1. You used percentages, but kept the "1". This is not correct. If you work in percentages, then

J = true positive PERCENTAGE + true negative PERCENTAGE - 100.

Assuming that you get the maximum at p=0.12 (check this), this is what you do. You use the fitted logit equation from your output:

logit(.12) = -4.71 + 0.0231X,

where X is your predictor. This gives:

-1.99 = -4.71 + 0.0231X, or

X = (-1.99 + 4.71)/0.0231 = 117.6. This is your cut-off.

Looking at your fitted curve at the end of your output, this looks about right.

Regular Contributor
Posts: 173

Re: ROC in SAS- obtaining a cut-off value

@ lvm: this is mighty helpful!. Thanks a lot! Based on the youden's J index and the  above calcualtions (that you've provided), the cut-off value does match with the clinically relevant cut-off value, which I had used earlier in my analyes. The reviewers had asked for a statistical justification to substantiate the cut-off based on ROC analyses, and I am happy that I have it now.

Gretaly appreciate your time and help!

Ashwini

Learner
Posts: 1

Re: ROC in SAS- obtaining a cut-off value

Hi

I am also trying to back calculate a particular conconcentration using Youden's Index.  However, I have been using a different software package as I have a continuous dataset.  Could you please explain how you derived the values -4.71 and 0.0231, i.e. what varables have been used in a regression. Is this something I could do manually by graphing respective variable in excel and getting a trend line and regression equation.  I too tried to manually generate the value -1.99 and the closest I got was -1.7, is this a natural log or log to some base value? Thanks for any assistance you are able to provide.

Regards

N/A
Posts: 1

Re: ROC in SAS- obtaining a cut-off value

I am facing a similar issue and found the above helpful.  I have a couple of follow up questions if you don't mind (for both Ashwini_uci and lvm):

  1. Is the cut point I now get model-based vs. observed? In other words, are we in essence back-calculating the cut point(s) as opposed to being able to match each observation in the OUTROC dataset back to the observed data that were tested to produced the sensitivity and specificity in the first place?
  2. Noticed log(e) was used to calculate the logit.  Any reason for selecting that base vs log(10) instead?

Also just to add a possible solution if not just looking for a single "best" cut point, I received this code from a SAS consultant who I was connected with when I contacted SAS Support directly:

Hi David:

If you have just a single X variable then you could solve for it.  Something like this would work:

data test;

   seed=2534565;

   do i=1 to 20;

      x1=ranuni(seed);

      logit=-2 + 2*x1;

      p=exp(-logit)/(1+exp(-logit));

      if ranuni(seed)>p then y=1; else y=0;

      output;

   end;

   drop seed i p logit;

run;

proc logistic data=test outest=parms(keep=intercept x1);

   model y=x1/ outroc=out1;

run;

data cutpoints;

set out1;

if _n_=1 then set parms;

x1_cut=(log(_prob_/(1-_prob_))-intercept)/x1;

proc print data=cutpoints;

var _sensit_  _1MSPEC_ _prob_ x1_cut;

run;

Sincerely,  

Rob Agnelli  

Principal Technical Support Statistician

SAS

Thanks,

David

Frequent Learner
Posts: 1

Re: ROC in SAS- obtaining a cut-off value

Hi Dverbel,

Is the above formula for getting the cut-off value is correct.? I am not sure about the formula.
Ask a Question
Discussion stats
  • 10 replies
  • 12033 views
  • 6 likes
  • 6 in conversation