# Difficulty with logistic regression: logit transformation is non-linear

I am trying to perform a logistic regression to model likelihood of receiving a procedure given a certain diagnosis. There are several covariates to analyze but one of the main ones is patient age. As a background to understanding the data, the incidence of this disease is highest among younger individuals and it is possible to understand outcomes as a dichotomous variable represented by “requires X procedure” or “does not require X procedure.”

My hypothesis was that because the incidence of this disease is lower in older individuals, it is possible that the likelihood of a poor outcome is higher due to delay in diagnosis (with the potential for many confounders that I would include in the analysis as best as possible). When I analyzed the distribution of the data, on first glance it appears that this may be the case:

Presented as percent receiving "X" in equal weight age bins:

The trend in younger individuals has been described, but not the trend in older individuals.

However, when I compute the logistic regression, the model fits very poorly due to the non-linear relationship. See the Negelkerk R-squared Hosmer and Lemeshow statistics below. Looking at the classification table, the sensitivity of the model is 0, which I believe I should interpret as the model correctly predicting none of the patients who undergo the procedure.

Analyzing the change in deviance and Cook’s distances shows a pattern to the model’s error, as expected due to the non-linear relationship.

Although I understand that the linearity assumption of the logistic regression is frequently violated, it seems obvious that this violation is too flagrant. However, I am at a loss for how to appropriately combine a non-linear transformation and a logistic regression. I would like to be able to describe an adjusted odds ratio for risk of procedure binned by age, if indeed it is significant.

Computing the regression with AGE and AGE^2 as terms increases the sensitivity slightly (to 8%) but the Negelkerk R-squared is still 0.042 and the Hosmer and Lemeshow statistic is 0.000. Adding a cubed term increases sensitivity to 11%, N-R-squared is 0.049 and H+L stat is 0.085. The change in deviance plot appears slightly more favorable:

My question now is two-part: 1) Is there any transformation that would help the model fit better at the extremes? (Or simply increase sensitivity?) 2) How would I combine the exponentiated "B" coefficients to interpret one odds ratio as a function of age? My intuition is to somehow solve the B1,AGE^3+B2,AGE^2+B3,AGE+constant expression for a series of arbitrary age bins and combine the confidence intervals in a similar fashion, but this is definitely something I am not confident about.

Once again, thank you for any help or direction to information/tutorials!

• Well, your plots indicate that the effect of AGE is non-linear, even non-monotone, so at the least you should include a quadratic term in age!, or use, maybe, a spline for age, like offered by R package mgcv. – kjetil b halvorsen Jun 4 '15 at 14:12
• Hi Kjetil, thank you for your advice! Unfortunately, I don't have any experience with R and am learning SPSS as I go along. If I were to apply a quadratic transformation to age before incorporating it into the logistic regression, would I still be able to interpret an adjusted odds ratio? – gch Jun 4 '15 at 21:09
• You should include age both as is (linear scale) and in addition its square, so you get two columns representing age. And yes, you can still interpret the odds ratio. – kjetil b halvorsen Jun 5 '15 at 14:21
• I think I understand the direction this is heading, do you think there is a better transformation I could try? (See edits) – gch Jun 5 '15 at 19:13
• It would be very helpful to see a useful exploratory analysis of the data, such as shown at stats.stackexchange.com/a/138660 (but with dispersion statistics replaced by logits of means). – whuber Jun 5 '15 at 19:44