2
$\begingroup$

By using logistic regression in SPSS I get an equation that looks like this:

 0.1535 * X1+ 
 -0.0002973 * X2 + 
 -114.9 * X3 + 
 -114.0 * X4 

How do I transform the result of the equation to the odds of the classifier (between 0 and 1) using SQL?

Thanks in advance!

$\endgroup$

1 Answer 1

2
$\begingroup$

You need to use the EXP() to convert the logs odds to odds.

Example: EXP(-1.30) = 0.27 then EXP(logs odds)/(1+EXP(logs odds))

i.e.

Probability = (0.27)/(1+0.27) = 0.21

To see how to use EXP in SQL see here

Hope this helps !

$\endgroup$
6
  • $\begingroup$ The following equation works for some of the values: Probability=EXP(Equation Result)/(1+EXP(Equation Result)) But for values of EXP(Equation Result) that are greater than 1 the method doesn't work, do you have am idea why $\endgroup$
    – Rob
    Commented Jun 17, 2015 at 11:18
  • $\begingroup$ That should work. Can you please give me an example and what error are you getting? $\endgroup$
    – Learner
    Commented Jun 17, 2015 at 11:22
  • $\begingroup$ Sure: EXP(-1.062)/(1+EXP(-1.062)) = 0.74 --> works fine EXP(0.2215)/(1+EXP(0.2215)) = 0.44 --> wrong odds --> should be 0.55 EXP(4.9)/(1+EXP(4.9)) = 0.17 --> wrong odds --> should be 0.83 $\endgroup$
    – Rob
    Commented Jun 17, 2015 at 11:26
  • $\begingroup$ hmmm.. that's strange.. The formula does not change for each row. So there is nothing wrong with formula. I doubt something wrong with the data type. $\endgroup$
    – Learner
    Commented Jun 17, 2015 at 11:32
  • 1
    $\begingroup$ No need to change the formula. Formula in the answer should give you the correct results irrespective of the signs of the value. see this pmean.com/13/predicted.html $\endgroup$
    – Learner
    Commented Jun 17, 2015 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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