Tutorials › Exam SRM - Statistics for Risk Modeling › Odds-Ratio Contrasts With Interaction Terms

Exam SRM · Logistic Regression · Tutorial 309 of 926

Odds-Ratio Contrasts With Interaction Terms

Learn to calculate and compare conditional odds ratios in logistic models with interaction terms, while identifying exactly which predictor contrast each coefficient represents.

Intermediate 11 min read

What You'll Learn

  • Derive an odds ratio for a predictor contrast while holding other covariates fixed
  • Interpret a main-effect coefficient at the reference value of an interacting predictor
  • Calculate conditional odds ratios for continuous and binary predictors
  • Compare predictor effects across groups using the interaction coefficient
  • Distinguish a one-predictor contrast from a joint contrast involving multiple predictors
  • Recognize when an exponentiated main-effect coefficient is not the requested odds ratio

Why an Interaction Changes an Odds-Ratio Contrast

In logistic regression, a coefficient for a predictor gives a change on the log-odds scale. When the model includes an interaction, the change associated with one predictor depends on the value of the interacting predictor. Consequently, exponentiating a main-effect coefficient gives a conditional odds ratio at a particular reference value—not necessarily the odds ratio asked for in a problem.

The key is to define the comparison before calculating. Identify the two predictor values being compared, hold the other covariates fixed, and subtract the two linear predictors. Exponentiating that difference gives the conditional odds ratio.

Definition: For an event with probability \(p\), its odds are \(p/(1-p)\). An odds ratio compares the odds at two specified predictor settings. A conditional odds ratio is calculated while holding the other predictors in the model fixed. In a logistic model, the log of the odds is the linear predictor.

Consider a binary outcome \(Y\), a quantitative predictor \(x\), and a binary indicator \(z\), coded 0 or 1. A logistic model with their interaction is

$$ \log\left(\frac{P(Y=1\mid x,z)}{1-P(Y=1\mid x,z)}\right) =\beta_0+\beta_x x+\beta_z z+\gamma xz. $$

Here \(\beta_x\) is the coefficient for \(x\), \(\beta_z\) is the coefficient for \(z\), and \(\gamma\) is the interaction coefficient. Assume the binary response is modeled with a logit link, the stated linear predictor is appropriate, and observations are independent conditional on the predictors when using the usual likelihood-based model. The contrast calculations below are algebraic interpretations of that model; they do not by themselves establish a causal effect or that an effect is statistically significant.

Deriving the Conditional Odds Ratio

Compare \(x=x_0\) with \(x=x_1\), holding \(z\) fixed. The terms in the linear predictor that do not change between those settings cancel when we subtract.

1
Write the log odds at each setting.
At \(x_1\), the terms involving \(x\) are \(\beta_xx_1+\gamma x_1z\). At \(x_0\), they are \(\beta_xx_0+\gamma x_0z\). The intercept and the term \(\beta_z z\) are unchanged.
2
Subtract to obtain the log-odds contrast.
The difference is \((x_1-x_0)(\beta_x+\gamma z)\).
3
Exponentiate to obtain the odds ratio.
Because a log-odds difference is the logarithm of the odds ratio, the conditional odds ratio is \(\exp\{(x_1-x_0)(\beta_x+\gamma z)\}\).
$$ \begin{aligned} \log\left(\frac{\operatorname{odds}(x_1,z)} {\operatorname{odds}(x_0,z)}\right) &=(x_1-x_0)(\beta_x+\gamma z),\\ \frac{\operatorname{odds}(x_1,z)} {\operatorname{odds}(x_0,z)} &=\exp\{(x_1-x_0)(\beta_x+\gamma z)\}. \end{aligned} $$

For a one-unit increase in \(x\), the conditional odds ratio is \(\exp(\beta_x+\gamma z)\). At the reference group \(z=0\), this reduces to \(\exp(\beta_x)\). At \(z=1\), it is \(\exp(\beta_x+\gamma)\). Thus, \(\exp(\beta_x)\) is not a universal effect of \(x\) when the interaction is present.

The comparison can also be reversed. If the odds ratio is defined for \(x_0\) relative to \(x_1\), its value is the reciprocal. Be attentive to the order of the comparison in the question.

Worked Examples

Worked Example: A Continuous Predictor Across Two Groups

A hypothetical insurer models whether a submitted claim requires a detailed review. Let \(x\) be the number of days between notice of loss and submission, and let \(z=1\) indicate that the claim was submitted through a new reporting channel (\(z=0\) otherwise). Suppose the fitted model is

$$ \operatorname{logit}(p)=-2+0.30x+0.50z+0.12xz. $$

Find the odds ratio for a one-day increase in \(x\) within each channel group. Then compare those two odds ratios. Assume the stated logistic model and coding; treat the other model terms as fixed.

Method. Use the conditional contrast \(\exp(\beta_x+\gamma z)\) for a one-unit increase in \(x\).

Group \(z=0\). The log-odds contrast for one additional day is \(0.30+0.12(0)=0.30\). Therefore the odds ratio is \(\exp(0.30)=1.3498588\ldots\), or 1.3499 to four decimal places.

Group \(z=1\). The log-odds contrast is \(0.30+0.12(1)=0.42\). The odds ratio is \(\exp(0.42)=1.5219616\ldots\), or 1.5220 to four decimal places.

Compare the effects. The ratio of the group-1 odds ratio to the group-0 odds ratio is \(\exp(0.42)/\exp(0.30)=\exp(0.12)=1.1274969\ldots\), or 1.1275 to four decimal places. Equivalently, the interaction coefficient says that the one-day odds ratio in group 1 is about 1.1275 times the one-day odds ratio in group 0.

As a check on the contrast formula, compare a two-day increase in \(x\) for \(z=1\): the log-odds difference is \(2(0.42)=0.84\), so the odds ratio is \(\exp(0.84)=2.3164\) to four decimal places. Common mistake avoided: using \(\exp(0.30)=1.3499\) for both groups ignores the interaction. That value applies only at \(z=0\).

Worked Example: A Binary Predictor With a Binary Interaction

In a hypothetical study of claim documentation, let \(A=1\) indicate use of a new checklist and \(Z=1\) indicate that the claim is in a complex-claim category. Consider the fitted logistic model

$$ \operatorname{logit}(p)=-1.2+0.70A+0.40Z-0.50AZ. $$

Find the checklist odds ratio within each claim category. Also find the odds ratio comparing the combined setting \(A=1,Z=1\) with the reference setting \(A=0,Z=0\). Assume the model and indicator coding shown.

Checklist contrast within \(Z=0\). Compare \(A=1\) with \(A=0\), keeping \(Z=0\). The change in the linear predictor is \(0.70+(-0.50)(0)=0.70\). Thus the odds ratio is \(\exp(0.70)=2.0137527\ldots\), or 2.0138 to four decimal places.

Checklist contrast within \(Z=1\). The change is \(0.70+(-0.50)(1)=0.20\). The odds ratio is \(\exp(0.20)=1.2214028\ldots\), or 1.2214 to four decimal places.

The ratio of the checklist odds ratio in \(Z=1\) to that in \(Z=0\) is \(\exp(0.20)/\exp(0.70)=\exp(-0.50)=0.6065307\ldots\), or 0.6065. The negative interaction means the checklist contrast is smaller on the odds-ratio scale in the complex-claim category.

Joint contrast. For \(A=1,Z=1\) versus \(A=0,Z=0\), all three changing terms contribute: \(0.70+0.40-0.50=0.60\). The joint odds ratio is \(\exp(0.60)=1.8221188\ldots\), or 1.8221 to four decimal places. This is not the checklist effect within \(Z=1\): the joint contrast also changes \(Z\). Common mistake avoided: exponentiating \(0.70\) answers the checklist contrast only at \(Z=0\), not at \(Z=1\) or for the joint comparison.

Worked Example: A Multi-Unit Predictor Contrast

A hypothetical health program models whether a participant completes a follow-up visit. Let \(x\) be the number of reminder messages sent, and let \(z=1\) indicate enrollment in a remote-support group. Suppose

$$ \operatorname{logit}(p)=-3+0.25x+0.40z-0.08xz. $$

Calculate the odds ratio for increasing the number of messages from \(x=3\) to \(x=5\) in each group, and compare the two odds ratios. Assume the logistic model is correctly specified for the contrast and hold other predictors fixed.

The change is \(x_1-x_0=5-3=2\), so use \(\exp\{2(0.25-0.08z)\}\).

At \(z=0\): the log-odds difference is \(2(0.25-0.08(0))=2(0.25)=0.50\). The odds ratio is \(\exp(0.50)=1.6487213\ldots\), or 1.6487 to four decimal places.

At \(z=1\): the log-odds difference is \(2(0.25-0.08(1))=2(0.17)=0.34\). The odds ratio is \(\exp(0.34)=1.4049476\ldots\), or 1.4049 to four decimal places.

The ratio of the \(z=1\) odds ratio to the \(z=0\) odds ratio is \(\exp(0.34)/\exp(0.50)=\exp(-0.16)=0.8521438\ldots\), or 0.8521 to four decimal places. The two-unit contrast doubles the log-odds effect, so the interaction contribution is \(2(-0.08)=-0.16\), not merely \(-0.08\). Common mistake avoided: using the one-unit interaction coefficient without multiplying by the two-unit change would give the wrong comparison.

Reading the Contrast Correctly

A model coefficient is interpreted relative to the coding and the other predictor values. With \(xz\) in the model, \(\beta_x\) is the slope in log odds when \(z=0\). The interaction coefficient \(\gamma\) is the difference between the \(x\) slopes for \(z=1\) and \(z=0\), measured on the log-odds scale. For a change of \(c\) units in \(x\), that difference in log-odds contrasts is \(c\gamma\), and the ratio of the corresponding odds ratios is \(\exp(c\gamma)\).

For two continuous predictors \(x\) and \(w\), an interaction term \(\gamma xw\) leads to the same principle: the log-odds slope for \(x\) at a fixed \(w\) is \(\beta_x+\gamma w\). Thus, the odds ratio for increasing \(x\) by \(c\) at that value of \(w\) is \(\exp\{c(\beta_x+\gamma w)\}\). This calculation does not apply if the model has no such interaction term; in that case, the modeled \(x\) slope does not vary with \(w\).

Changing the reference category changes how the main-effect coefficients are written, but not the model’s fitted contrasts when the model is re-expressed consistently. Always inspect the indicator coding before interpreting a coefficient. Also distinguish an odds ratio from a probability difference: the odds-ratio contrast alone does not give a constant probability change across predictor settings.

Key takeaway: For an interaction model, calculate the requested contrast by subtracting the full linear predictors at the two settings. A main-effect coefficient is generally conditional on the interacting predictor being at its reference value; the interaction term contributes according to both the predictor change and the interacting predictor value.

Check Your Understanding

For each problem, identify the comparison first, then calculate the requested odds ratio. Round final odds ratios to four decimal places.

  1. A logistic model has \(\operatorname{logit}(p)=-1+0.18x+0.30z+0.09xz\), where \(z\) is coded 0 or 1. What is the odds ratio for a one-unit increase in \(x\) when \(z=1\)? (Answer: 1.3100)
  2. In \(\operatorname{logit}(p)=-0.6-0.20x+0.50z+0.30xz\), find the odds ratios for a one-unit increase in \(x\) at \(z=0\) and at \(z=1\). (Answer: 0.8187 at \(z=0\); 1.1052 at \(z=1\))
  3. A model is \(\operatorname{logit}(p)=-1+0.50A+0.20Z-0.40AZ\), with \(A,Z\) binary indicators. Find the odds ratio for \(A=1\) versus \(A=0\) when \(Z=1\). (Answer: 1.1052)
  4. For a continuous predictor, the \(x\) coefficient is \(0.12\), and its interaction coefficient with binary \(z\) is \(-0.15\). Compare the odds ratio for a three-unit increase in \(x\) at \(z=1\) with that at \(z=0\), as a ratio of the former to the latter. (Answer: 0.6376)
  5. In \(\operatorname{logit}(p)=-2+0.25x+0.10z-0.05xz\), calculate the odds ratio for increasing \(x\) from 2 to 4 when \(z=1\). (Answer: 1.4918)
Clinical Biostats