I have a dependent variable "response" as binary 1 = response, 0 = no response (for surgery). I have an independent variable of a certain measurement in degrees (continuous/ordered variable).

A logistic regression model shows an association of p=0.07 which is pretty good and a two-way fit plot with linear prediction also looks pretty good:enter image description here

So I have the idea of calculating a cut-off point for this radiologic measurement, seeing as it's strongly associated to my outcome. However, doing a roctab, the graph looks like this:

enter image description here

Am I doing something wrong here? That ROC curve is terrible, worse than a coinflip, despite the data looking so good before?


In practice it means that your predicted values are negatively correlated with your outcome variable: when the true value is 1, your predicted values are close to zero, and vice versa. You can flip the ROC curve by subtracting from 1 your predicted values.

ROC curve can be plotted by either using "lroc" or by first generating a variable with your predictions and then using "roctab refvar classvar, graph", where refvar is your outcome variable and classvar is your prediction.

Here is an example:

sysuse auto, clear
logit foreign displacement
predict prediction, p
roctab foreign prediction, graph


gen reverse_prediction = 1 - prediction
roctab foreign reverse_prediction, graph

enter image description here

corr foreign prediction // = 0.6994
corr foreign reverse_prediction // = -0.6994

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.