The slides contain speaking notes that you can view by pressing ‘S’ on the keyboard.
20.1 Case session 11: “”
At AalboR Statistical Hospital, a new exercise-based cardiac assessment protocol has recently been introduced following an initial data review suggesting that patients with lower max heart rate are more likely to have underlying heart disease. Based on this, some clinicians have started using the max heart rate during exercise as a quick indicator when evaluating chest pain patients.
However, during a recent internal meeting, a cardiologist raises a concern:
“I’m not convinced this applies to our patients. Especially those who develop chest pain during exercise — their heart rate response might behave differently. If that’s true, we could be misinterpreting results in a subgroup of patients. I want to see this association for myself”
You are asked to explore the hospital’s patient data to assess whether the relationship between Age and max heart rate — and the interpretation of max heart rate more generally — appears consistent across patients, or whether it differs depending on exercise-induced angina, sex, or other patient characteristics.
You are tasked with the decision: Should this new assessment approach be used broadly, or are there patient groups where it may be misleading?
Step 1: Write separate equations for each group No heart disease (hd = 0)
Substitute hd = 0:
$ ⁄bar{Y} = 213.93−1.06(age) $
Interpretation:
For people without heart disease, each additional year of age is associated with about 1.06 units lower predicted outcome. Heart disease (hd = 1)
Substitute hd = 1:
$ Y^ =213.93−1.06(age)−53.84+0.689(age) $
Combine terms:
\(Y^=160.09−0.368(age)\)
Interpretation:
For people with heart disease, each additional year of age is associated with only about 0.37 units lower predicted outcome. The age effect is less negative because of the positive interaction term.
20.5.2 Step 2: Plug in specific ages
Age = 40
No heart disease: 213.93−1.06(40)=171.67
Heart disease: 160.09−0.368(40)=145.37
Difference: 145.37−171.67=−26.30
At age 40, heart disease is associated with about 26 units lower predicted outcome.
Age = 70
No heart disease: 213.93−1.06(70)=140.00
Heart disease: 160.09−0.368(70)=134.34
Difference: 134.34−140.00=−5.66
At age 70, heart disease is associated with only about 6 units lower predicted outcome.
20.5.3 Step 3: Interpret the interaction
The interaction coefficient is: 0.689
This means that the effect of heart disease becomes 0.689 units less negative for every additional year of age.
In other words: The difference between the heart disease and no-heart-disease groups shrinks by about 0.689 units for each additional year of age.
We can again plug the values in to examine this:
Age HD=0 HD=1Difference (HD−No HD)40171.67145.37-26.3050161.11141.69-19.4160150.54138.01-12.5370139.98134.32-5.66
Students often find the table easier than interpreting the interaction coefficient directly because they can see how the gap between groups changes with age.
Warning:
It is essential to check the order of estimates when specifying hypothesis tests using positional indices like b1, b2, etc. The indices of estimates can change depending on the order of rows in the original dataset, user-supplied arguments, model-fitting package, and version of `marginaleffects`.
It is also good practice to use assertions that ensure the order of estimates is consistent across different runs of the same code. Example:
```r
mod <- lm(mpg ~ am * carb, data = mtcars)
# assertion for safety
p <- avg_predictions(mod, by = 'carb')
stopifnot(p$carb[1] == 1, p$carb[2] == 2)
# hypothesis test
avg_predictions(mod, by = 'carb', hypothesis = 'b1 - b2 = 0')
```
Disable this warning with: `options(marginaleffects_safe = FALSE)`
This warning appears once per session.
Consider for example the GDP and terrain ruggedness problem. The interaction there has two equally valid phrasings.
How much does the influence of ruggedness (on GDP) depend upon whether the nation is in Africa? How much does the influence of being in Africa (on GDP) depend upon ruggedness?
21.1 Symmetry of the Linear Interaction
Consider McElreath’s GDP and terrain ruggedness example.
One might ask:
How much does the effect of terrain ruggedness on GDP depend on whether a nation is in Africa?
How much does the effect of being in Africa on GDP depend on terrain ruggedness?
These sound like different questions, but in a linear model they are mathematically identical.
The quantity \(G_i\) plays the same role for the Africa effect that \(\gamma_i\) played for the ruggedness effect.
21.1.1 Key takeaway
The interaction coefficient \(\beta_3\) simultaneously describes
how the effect of ruggedness changes across Africa/non-Africa, and
how the effect of Africa changes across levels of ruggedness.
In a linear model, interactions are symmetric. The choice of which variable is called the “predictor” and which is called the “moderator” is often a matter of interpretation rather than mathematics.
The following object is masked from 'package:ggplot2':
set_theme
data(efc)m<-lm(neg_c_7~c12hour+e16sex+c12hour:e16sex, data =efc)# fit model with 3-way-interactionfit<-lm(neg_c_7~c12hour*barthtot*e16sex, data =efc)# select only levels 30, 50 and 70 from continuous variable Barthel-IndexsjPlot::plot_model(fit, type ="pred", terms =c("c12hour", "barthtot [30,50,70]", "e16sex"))
where:
neg_c_7 = caregiver burden (outcome) c12hour = hours of care provided sex = caregiver sex
Then ask the two interaction questions:
How much does the association between caregiving hours and burden depend on caregiver sex?
and
How much does the difference between male and female caregivers depend on caregiving hours?
Students usually perceive these as different questions, but the interaction coefficient is the same parameter in both cases.