1
$\begingroup$

I am using logistic regression to predict the probability of being a bad customer. I need to transform each independent variable to make sure it has a strong linear relationship with the log-odds of my target. One variable has a upper U-shape when I plot the variable value against the log-odds. How should I transform it so I won't over-predict the lower group and under-predict the upper group?

enter image description here

EDIT: I tried using square, but it did not give me a better/linear-er line. enter image description here

$\endgroup$
3
  • 4
    $\begingroup$ Why do you think adding a squared term to your model does not work? $\endgroup$ Sep 30, 2019 at 14:42
  • $\begingroup$ I added the plot when I created a square term. It still does not look linear. $\endgroup$
    – skylar1218
    Sep 30, 2019 at 14:58
  • $\begingroup$ Response driven transformations like this will lead to overfitting, especially a problem with smallish data. $\endgroup$
    – Michael M
    Sep 30, 2019 at 15:55

2 Answers 2

3
$\begingroup$

No transformation is necessary to achieve linearity, because that isn't required. You simply have a curvilinear relationship between this variable and the outcome. So add a squared version of this variable in addition to the untransformed version. If you need a test of this variable, you would perform a simultaneous test of both terms.

It may help you to see a couple of my previous answers where this is demonstrated (in R):

$\endgroup$
2
$\begingroup$

You can use a spline of the independent variable. These allow very flexible fitting of almost any shape of relationship between the IV and the DV (or, in this case, the log odd of the DV).

$\endgroup$
2
  • $\begingroup$ For that, should I do: 1. trans_var1 = (var <= 12) and trans_var2 = (var > 12) or, 2. trans_var1 = min(var, 12) and trans_var2 = max(var ,12)? $\endgroup$
    – skylar1218
    Sep 30, 2019 at 20:35
  • $\begingroup$ You should do a spline and see what arises. $\endgroup$
    – Peter Flom
    Sep 30, 2019 at 23:54

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.