# How to test a curvilinear relationship in a logistic regression

I was looking for some information about curvilinear relationships (quadratic function, to be precise) in logistic regression online, and couldn't really find much about it.

I am interested if that could be done, and if so, how can I do it in SPSS? Do I just square the variable that I want to test for a curvilinear relationship and add it into the model like any other variable? Or is there some special way of doing it?

## 2 Answers

"curvilinear" could mean anything geometrically not a straight line on the scale being used. So, that could mean many things, including behaviour best tackled with powers of another variable, exponentials, logarithms, trigonometric and hyperbolic functions, etc., etc.

Using logistic regression does not change what is standard in any kind of regression-like modelling: You can have whatever predictors (so-called independent variables) in your model that make sense, so long as there are sufficient data.

Those general statements aside, trying a quadratic term in your model as well as a linear term is often a good simple way of adding some curvature. Because you are using a logit scale, intuition needs refining here. In particular, if your coefficient on the squared term is negative, you are fitting a kind of bell shape on the probability scale. This is often a feature in e.g. ecology where probability of occurrence of organisms is greatest for some intermediate value of an environmental predictor. In simple terms, it can be too hot, about right, too cold, and so forth. See http://www.cambridge.org/gb/knowledge/isbn/item5708032/ for one good account.

I trust that others will add advice about SPSS.

• I forgot to specify that by curvilinear I meant a quadratic function - in one bend in the regression line. – IvLi Jun 4 '13 at 11:00
• "curvilinear" can't mean just "quadratic". If your question boils down to how I do fit a quadratic, then the answer is using a linear and a squared term as predictors. Newtonian mechanics aside, there are rarely theory-based reasons for fitting quadratics; at best they are used empirically. – Nick Cox Jun 4 '13 at 11:06

In addition to @Nick's excellent answer, let me just add some practical things about the modelling of nonlinear relationships that I've come across in my work. In epidemiology, for example, we are often faced with nonlinear dose-response relationships. An example would be the relationship between number of cigarettes smoked per day and the risk of death. One common approach is to categorize the exposure, but this is suboptimal. Two relatively quite common methods to fit nonlinear relationships are fractional polynomials and splines. These three papers offer a very good introduction to both methods: First, second and third. There is also a book. These methods are very flexible to model nonlinear relationships and they are not limited to applications in epidemiology and can be applied in other frameworks. As @Nick said: nonlinear relationships are not limited to linear regression and can be used in logistic regression too (and others, of course). Just pay attention that the scale is different (logit).

Regarding SPSS: SPSS doesn't seem to support fractional polynomials at the moment but Stata, R and SAS do. Splines on the other hand seem to be supported.