Statalist folks,

I am trying to code a function into Stata and need some assistance.

I have a diagnostic test with a symmetric ROC, parameterized as follows: (β=0 as the curve is symmetrical)

Δ=DOR+βS

Δ= logit(s(z)) - logit(1-c(z))

S= logit(s(z)) + logit(1-c(z))


DOR = Diagnostic Odds Ratio | z is the positivity threshold | c(z) is the specificity with threshold z | s(z) is the sensitivity at threshold z

I am trying to find a positivity threshold, z, that will maximize the test's value below:



I am trying to figure out a way to find the S and C (sensitivity and specificity) to maximize a value quantity, X:

X = max ( E2 - E1, E2- E3 , 0 )


E1 = 0
E2 = 0.7
E3 = -0.3 * (1-C) + [(0.15 * S) - (0.45 (1-C)) ] * 0.25


Thanks very much for help!