# Should the logistic regression equation always result in a value between 0 and 1?

I am a medical scientist but an amateur statistician (not even amateur). I have a simple question. Here is the output from a logistic regression examining a number of variables which may predict if a doctor will perform a biopsy in a patient or not. So the dependent variable is "biopsy or not". It's been run in 24240 doctor-patient consultation. What I want to do is evaluate the relationship between these variables and biopsy decisions in each INDIVIDUAL doctor-patient consultation using the logistic regression equation and these coefficients.

My primary question is:

If apply:

    age * -.02742 + dlco * 0.0053058 + pioped_intermediate * 1.244477 + pioped_ipf_intermediate * 0.172851 + .6047641


to an individual doctor-patient consultation, am I correct in thinking I should get a result between 0 and 1? If I am getting values that range from -1.6 to +1.5 does that indicate there is a mistake in my calculations?

I hope this makes sense (and its acceptable to upload a screenshot).

## 1 Answer

No. Your linear function could return any real value. You are supposed to put that value into the logistic function to get a probability value between 0 and 1. That's really the whole trick of logistic regression: to create a mapping between a scale with range $[0, 1]$ and range $[-\infty,+\infty]$.

• Thanks, David - are you saying the equation is the linear function and that value goes into Log(p/1-p)? – GhostRider Aug 10 '17 at 13:47
• It actually goes into the inverse function of that: exp(x) / (1 + exp(x)) – Matthew Drury Aug 10 '17 at 13:51
• Almost. Your expression is the linear function, and its value goes into the logistic function $p = e^t/(e^t +1)$, which the inverse of the logit function $t = \ln(p / (1-p))$. – David Wright Aug 10 '17 at 13:51
• Many thanks - this works as I expected. Sorry for the ridiculously basic question. – GhostRider Aug 10 '17 at 13:53
• You are at liberty to put your cut-off anywhere you want depending on the costs and benefits of the right and wrong decisions (true, false positives, true, false negatives). In the absence of that information 0.5 is conventional. – mdewey Aug 10 '17 at 14:38