At AalboR Statistical Hospital, clinicians have been reviewing data from patients who underwent exercise testing as part of their cardiac evaluation.
One of the variables recorded during the test is maximum heart rate. When looking at the data as a whole, the clinicians notice an interesting pattern: patients with heart disease tend to have lower maximum heart rates than patients without heart disease.
At first, this seems fairly straightforward.
During a case discussion, however, a cardiologist points out something that makes the pattern less convincing:
“Before we interpret this relationship, we should remember that maximum heart rate also changes with age. A maximum heart rate that seems unusually low for a younger patient may not be unusual for an older patient.”
This prompts the team to look more closely at the data.
They begin comparing patients of different ages and notice that the relationship between maximum heart rate and heart disease does not look quite the same everywhere in the dataset.
What initially appeared to be a simple relationship may depend on who the patient is.
You are asked to investigate this pattern in the hospital’s patient data. The challenge is to understand what happens to the relationship between maximum heart rate and heart disease when we consider patients conditional on their age — and whether the relationship itself changes across ages.
The findings may reveal something that is easy to miss when looking only at the overall data.
Case supplemental material
Boxplot showing decreased max heart rate for heart disease patients
Scatter plot supporting the cardiologist’s statement
Follow-up data visualization based on the cardiologist’s statement
AalboR Statistical Hospital internal review data at the meeting
Deadly asbestos - according to whom?
Anyone knows what this is?
Read section 13.4
Conditional bells or cigarrts
conditioning: Dependence on state
everything is conditional
on data
on model
Interaction: Influence of predictor conditional on other predictor
Conditional modulation or interaction
When variable \(z\) changes the effect of \(x\) on outcome \(y\)
Do you have examples in your life?
Talk to your neighbor!
The additive assumption and linear assumption of regression
Reading task 13.5
The additivity assumption
the association between a predictor \(X_j\) and the response Y does linear not depend on the values of the other predictors.
The linearity assumption
the change in the response Y associated with a one-unit change in \(X_j\) is constant, regardless of the value of \(X_j\).
Making a regression model
Age is continuous: 0 — 125
Heart disease is binomial: {0,1} — yes or no.
\[
MaxHR_i = α + β_1Age_i
\]
Now, what do we do with HD?
One question, two models…
We could split the data in two:
Those that have heart disease and everyone else…
(a) Regression fit for each group
… but no answer
Call:
lm(formula = MaxHR ~ Age, data = subset(hd_data, HD == "yes, heart disease"))
Coefficients:
(Intercept) Age
160.0856 -0.3678
Call:
lm(formula = MaxHR ~ Age, data = subset(hd_data, HD == "no heart disease"))
Coefficients:
(Intercept) Age
213.928 -1.056
No estimates for the estimand: MaxHR ~ HD | Age
In words, is the effect of heart disease on max heart rate mediated by age?
No value from pooling (σ and other uncertainty estimates)
Let’s try something else!
Any ideas?
Adding the variable to a regression model is not enough
\[
MaxHR_i = Normal(μ_i, σ)
\]
\[
μ_i = α + β_1Age_i + β_2HD_i
\]
Only adjust intercept!
It adds a constant \(β_1HD_i\) but the slope remains identical…
Next, we make a simple linear model adding the two variables of interest.
3
Here, we load the {marginaleffects} package
4
We plot how the model predicts the max heart rate based on age for both patients with and without heart disease. Note how we add the model variable and give a string vector to the argument condition.
We know they should not be parallel
(a) Subset models
(b) Raw data
Figure 2
Reading task: Making non-additive terms in linear models
Read section 13.8: Making non-additive terms in linear models
Conditional multiplication
Consider the cancer risk explained by asbestos exposure (h) conditioned on smoking status (or pack-year).
Asbestos exposure (h) (\(X_1\))
smoking status (\(X_2\))
Interaction effect (\(X_1X_2\))
2
yes = 1
2
3
yes = 1
3
2
no = 3
6
3
no = 3
9
Conditional effects = Interaction effects
Additive models: Where the effect of one predictor does not depend on the other predictor.
Interaction models: Where the effect of one predictor can depend on the other predictor.
What if we have two continuous variables we allow to interact?
Meaning of parameters change when you add interaction:
The coefficients are now non-linear
coefficients in model without interaction:
change in outcome per unit change in predictor
e.g., when age increase 1 year, MaxHR increase 0.50 BPM
Coefficients within interactions:
Change in outcome per unit change in predictor when other predictor is zero
e.g., change in MaxHR per unit change in age when HD is zero
Interpreting continuous interaction
α: when x and z = 0
z: change in y per unit change z, when x = 0.
x: change in y per unit change x, when z = 0.
xz: interaction. Don’t even try… Just plot!
Pain relief as an example
Call:
lm(formula = MaxHR ~ Age + Chol + Age:Chol, data = hd_data)
Coefficients:
(Intercept) Age Chol Age:Chol
251.955403 -2.004447 -0.194792 0.004053
Unlike the HD condition {yes/no}, both Chol and Age have infinite values!
How to we plot that? 👀
Triptych plotting
Raising of the Cross, Rubens, 1610–11, Antwerp Cathedral
A triptych (/ˈtrɪptɪk/ TRIP-tik) is a work of art (usually a panel painting) that is divided into three sections, or three carved panels that are hinged together and can be folded shut or displayed open.
How in the world are we ever going to interpret this monster?! And now it’s a logistic regression, so the coefficients are in log-odds! 😅
Truth is — we can’t infer much (if anything at all) from the coefficients alone. We would need to do a marginal effect estimate, which we’ll cover in ?@sec-marginal-effects.
Example of interaction madness
Genetics x environment
We believe that genes are expressed conditional on lived experiences: