I am building a logistic regression model with a binary rating (High and Low) as the dependent variable and 40+ independent variables. One of the independent variable (Age) has a non-linear relationship (bimodal shape) with the dependent.

What is the best approach / transformation to deal with this? Are splines the best method? I feel splines make the model too complicated and hard to interpret especially if interactions are also included.

  • $\begingroup$ There is no one size that fits all. Could you try splitting the independent variable into bins and see the relationship with the dependent variable? $\endgroup$ Commented May 9, 2016 at 23:34
  • 2
    $\begingroup$ Because the response in a logistic regression is binary, could you explain what you mean by "non-linear relationship" or "bimodal shape"? $\endgroup$
    – whuber
    Commented May 13, 2016 at 15:56
  • $\begingroup$ @karthikbharadwaj The independent variable Age is already bucketed into 5-year bins. I do not want to bucket further to avoid losing more "information". $\endgroup$
    – user112920
    Commented May 14, 2016 at 4:10
  • $\begingroup$ @whuber The bimodal shape is seen when I smooth the Rating vs. Age plot (e.g. using loess) $\endgroup$
    – user112920
    Commented May 14, 2016 at 4:11

3 Answers 3


My recommendation: use age in years as is, without any binning, and represent it with regression splines. Or Try generalized additive models (GAMs.) See for instance Are both of these generalized additive models? (and search this site, many posts.)

One post with simple R code is Violation of linearity assumption in Logistic Regression.


I agree with Kjetil's answer, if you have age in years available.

If age was already binned into 5 categories, then splines probably won't work well as there are very few choices for the knots. You could try optimal scaling. This is available in the R package optiscale and in SAS PROC TRANSREG and probably in some other packages as well.

But binning throws away information (as you note in one of your comments). It can also distort the relationship. I wrote a blog post exploring this graphically: What happens when we categorize an independent variable? and a more general one: Why binning continuous data is almost always a mistake ,


IMO,Two approaches can be followed: 1)You can visualize how the target varies with the different age buckets 2) The most popular transformations used are log transformations or quadratic transformation. For each transformation, you can use cross-validation to check which one performs better


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.