# Thread: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

1. ## [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

Hi,

I am doing a project to identify variables that can predict rehospitalisations. There are a few categorical and continuous variables that I am considering. How do I transform the continuous variables such that the it has a linear relationship with the logit?

I am more adept at using SPSS but if advice is given for other statistical package, I am still willing to give it a try.

Thanks for the help.

2. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

First you should test to see if they are non-linear If you find them to be non-linear then a series of transformations using roots and powers can be used to make the data more linear. Tukey's ladder is the easiest place to start.

http://onlinestatbook.com/2/transformations/tukey.html

Whatever software you use the process is the same. You create new variables from the Y (most commonly although sometimes you transform X) applying the right power transformation until your relationship is linear. It is essentially a trial and error process - you start with the less extreme transformation and move to the more extreme ones until the relationship is linear.

Note that this process won't always work. Some relationships are inherently non-linear. In some cases this can be addressed, but I don't remember the process (which is complex at best).

3. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

I don't understand the question. The logit model (because of the link function) is inherently non-linear to begin with, so why should you check linearity?

4. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

The OP comment

How do I transform the continuous variables such that the it has a linear relationship with the logit?
The logit model is non-linear between the dichotomous Y and the predictor. It is linear between the logit and the predictor which is why you test for linearity in logistic regression.

Or so I have always been taught. If not that is a shock to me....

5. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

No, you're absolutely right noetsi. That's why it's a generalised linear model.

6. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

This is interesting as I've never used these ideas in applied research.

I suppose what you are saying is that you look at a plot of x and y and see if you find a straight line because the relationship should be linear? Is this correct?

7. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

Actually I don't use plots to detect non-linearity. I specify an interaction term between the predictor and it square. If this interaction term is significant for a given predictor non-linearity is indicated. In practice this rarely comes up with my (also applied only) analysis because virtually all of my predictors are dummy variables and they are always linear. Only the continuous ones (I almost never have) can be non-linear.

Correcting it would involve specifying a transformation (of either the X or Y) until the term is not signficant, although you could use the old fashioned method of looking at a graph to see when it becomes linear.

8. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

To paraphrase and confirm that I followed:

In logistic regression, you should check linearity between continous independent variable and the logit.
You can do this by introducing an interaction term consisting of a term multiplied by its quadratic term ((continous variable * continuous variable) * continuous variable) in the model. If significant you have non-linearity.

I wanted to veriry the continous(continous^2) and whether you would also incorporate the basic continous variable at the same time in the model.

9. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

Note that the formal test of this creates an interaction between a continuous variable and its log (so it is log*Continuousvar). This is Box Tidwell. I was told you could use the square of the continuous var instead of the log of it in the interaction term.

10. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

T&F??

Plus you keep the non-transformed variable still in the model?

11. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

I modified what I said considerably. You probably should look there instead of what I wrote oringally.

T&F is Tbachnick and Fidel - I thought we had used this code before.

You run the original variables and their interaction term as a predictor. It is the signficance of the interaction terms that matters, however for the test of linearity. T&F confuse this considerably in their comments on p 474-475 where they seem to be referencing the p value of the continuous variable itself. 443 and the comments I linked in my last post clarifies what you are really supposed to do, look at the interaction term.

Note also their modification of the alpha value given FW error discussed on 474

12. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

Thanks for the help! Using your method, I have managed to transform the logit equation such that it is linear. However, I am still unclear of what I should do now to include the changes into my logistic regression data. Could you help me with it?

Originally Posted by noetsi
First you should test to see if they are non-linear If you find them to be non-linear then a series of transformations using roots and powers can be used to make the data more linear. Tukey's ladder is the easiest place to start.

http://onlinestatbook.com/2/transformations/tukey.html

Whatever software you use the process is the same. You create new variables from the Y (most commonly although sometimes you transform X) applying the right power transformation until your relationship is linear. It is essentially a trial and error process - you start with the less extreme transformation and move to the more extreme ones until the relationship is linear.

Note that this process won't always work. Some relationships are inherently non-linear. In some cases this can be addressed, but I don't remember the process (which is complex at best).

13. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

I am not sure I understand the question. If you transformed a variable to make it linear you replace the non-linear variable with the new transformed one and then run the model as you would with any variable. Note that in interpreting the results you need to reference the transformed measurement (like refering to the logged variable rather than the original scale). Alternatively you can transform back to the original variable after running the model (which is highly reccomended by authors, but which I have never done myself so can not provide details of the interpretation that results).

14. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

Thanks for the reply. But in binary logistic regression, I am transforming the logit(Ln(p/(1-p))) isn't it? It is not the y, which is a 1 or 0, that I will use to run in the logistic regression.

Originally Posted by noetsi
I am not sure I understand the question. If you transformed a variable to make it linear you replace the non-linear variable with the new transformed one and then run the model as you would with any variable. Note that in interpreting the results you need to reference the transformed measurement (like refering to the logged variable rather than the original scale). Alternatively you can transform back to the original variable after running the model (which is highly reccomended by authors, but which I have never done myself so can not provide details of the interpretation that results).

15. ## Re: [SPSS] Multivariable logistic regression - how to transform to achieve linearity?

All the transformations I have seen have been of the raw data not of a calculated logit. Even with Y you are transforming the 0 and 1 (that is the original data). But there could well be transformations I have not worked with.