4 Handling continuous variables: categories, straight lines, and splines
How you put continuous variables such as age, blood pressure, and BMI into a model strongly affects the results. A common approach is to enter them in categories, like “under 50 / 50 and over”, but this has two problems.
4.1 Coarsely categorizing a confounder leaves confounding behind
For smoking and death (Chapter 1), we enter the confounder age in various forms.
- With age in 2 categories, the odds ratio for smoking is 1.39
- With 4 categories it is 1.56, and with a straight line or a spline it is 1.63
Within “under 50” there are still differences between people in their 30s and 40s, and the confounding due to smokers being younger within that group remains (residual confounding). The AIC (smaller means a better balance between fit to the data and simplicity) is also larger for the categorized models.
Strong confounders such as age are entered as continuous variables without categorizing (as a curve with splines if needed). If you do categorize, use fine categories. In the Mantel-Haenszel test in Chapter 7 of the chi-squared test hands-on, the result also changed when the age strata were made finer.
4.2 Categorizing the exposure loses information
Categorizing the exposure (the variable of interest) is also problematic. Let us look at systolic blood pressure and 24-year CVD.
The odds ratio of 2.02 for “140 or more vs below” treats a person at 141 mmHg the same as one at 200 mmHg, while putting 139 mmHg and 141 mmHg in different groups. With finer categories, compared with below 120, the odds ratios go 1.63 → 2.33 → 3.70, showing risk rising as blood pressure increases.
The problems with categorizing are:
- Tiny differences on either side of a cut point are treated as large differences, and differences within a category are ignored
- Power drops (dichotomizing is said to lose roughly as much information as discarding about a third of the participants)
- If cut points are chosen after looking at the data, you can pick a convenient result
4.3 Is a straight line good enough? Check with splines
Entering the variable as continuous now means assuming a “linear relationship” (for logistic regression, the log-odds is linear). With a natural spline (ns()), you can fit a smooth curve.
We compare models for the relationship between BMI and 24-year death.
The linear model can only say “the higher the BMI, the more deaths”, but the spline shows that people with low BMI also die more often (a J- or U-shape). Had we assumed a straight line, we would have missed the risk in thin people.
Possible reasons why people with low BMI die more often include losing weight because of illness (reverse causation) and smokers being thinner. Even when the shape of the curve is known, whether it is a causal shape must be examined separately using the ideas in Chapter 2.
- Coarsely categorizing a confounder leaves confounding behind (smoking OR 1.39 with age in 2 categories, 1.63 with continuous age)
- Categorizing the exposure loses information and power, and the results change with the choice of cut points
- When entering a continuous variable, check the linearity assumption with splines (BMI and death are J-shaped)