# ROC curve looking off compared to my results

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:

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:

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
lroc
predict prediction, p
roctab foreign prediction, graph


gen reverse_prediction = 1 - prediction
roctab foreign reverse_prediction, graph


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