Conditional manetees

Case 11: “Just send a quick summary”

Manetees and bombers

  • conditioning: Dependence on state
  • everything is conditional
    • on data
    • on model
  • Interaction: Influence of predictor conditional on other predictor

Coffee - sugar and sturring

TODO …

Heart rate decline as a function of age

Figure 1: Heart rate decline as a function of age.

\[ y_i = Normal(μ_i, σ) \]

\[ μ_i = α + β_AAge_i \]

The value of age

  • splitting the data is a bad idea
    • No estimates for the estimand: age | HD
    • No value from pooling (σ and other uncertainty estimates)

Figure 2: Heart rate decline as a function of age.

So how about adding heart disease as a dummy variable?

Dummy doesn’t work

Figure 3: Heart rate decline as a function of age and heart disease.

\[ y_i = Normal(μ_i, σ) \]

\[ μ_i = α + β_AAge_i + β_HH_i \]

Only adjust intercept!

  • It adds a constant β_HH_i but the slope remains identical

Interaction

Need to allow effect of age to dependt on heart disease status

\[ μ_i = α + β_AAge_i + β_HH_i \]

Need to allow effect of age to dependt on heart disease status

Interaction

\[ μ_i = α + γ_iA_i + β_HH_i \]

\[ γ_i = β_A + β_{HA}H_i \]

  • old direct effect of Age
  • linear effect of HD on slope

Interaction

\[ μ_i = α + γ_iA_i + β_HH_i = α + β_A + β_{HA}A_iH_i + β_HH_i \]

\[ γ_i = β_A + β_{HA}H_i \]

  • old direct effect of Age
  • linear effect of HD on slope

a linear model in a linear model

Adding an interaction

Figure 4: Heart rate decline as a function of age conditioned on heart disease.

\[ y_i = Normal(μ_i, σ) \]

\[ μ_i = α + β_AAge_i + β_HH_i + β_AAge_iβ_HH_i \]

Adding an interaction in R

model_interact <-
    lm(MaxHR ~ Age + HD + Age:HD,
    data = hd_data)

same_model_interact <-
    lm(MaxHR ~ Age * HD, # expands to Age + HD + Age:HD
    data = hd_data)

Interpreting interactions

It’s hard!

  • Add interaction -> other parameters change meaning
  • Influence of predictor depens upon multiple parameters and their covariation

Go to the website exercises (num?)

Exercises…

tmp

Symmetry of interactions

Linear interactiosn are bidirectional

In the context of maxHR:

  • if the effect of age depends on HD, then…
  • effect of HD also depends upon age

\[ μ_i = α + {\color{purple}{(β_A + β_AAge_iβ_HH_i)Age_i}} + β_HH_i \]

\[ = α + β_AAge_i + β_AAge_iβ_HH_i + β_HH_i \]

\[ = α + β_AAge_i + {\color{magenta}{(β_AAge_iβ_HH_i + β_H)H_i}} \]

The effect of HD depends upon age

Figure 5: Heart rate as a function of age conditioned on heart disease.

Thought experiment: Effect of getting HD

  • If I take a 30yo and give them HD, how will their maxHR change?

Plotting the slope

Thought experiment: Effect of getting age

  • If I make a patient with HD younger/older , how will their maxHR change?

Checking the estimates


 Age Estimate Std. Error      z Pr(>|z|)    S 2.5 % 97.5 %
  29  -33.874       7.24 -4.680   <0.001 18.4 -48.1  -19.7
  77   -0.821       6.19 -0.133    0.894  0.2 -13.0   11.3

Term: HD
Type: response
Comparison: yes, heart disease - no heart disease

What does it say?

Hypothesis testing the interaction


 Hypothesis Estimate Std. Error    z Pr(>|z|)   S 2.5 % 97.5 %
    b2-b1=0     33.1       12.6 2.62  0.00876 6.8  8.34   57.8

Type: response

Hypothesis-testing:

  • Now testing whether this effect is different.

Using {marginaleffects}

model_interact <-
    lm(MaxHR ~ Age + HD + Age:HD,
    data = hd_data)

plot_predictions(
    model_interact,
    condition = c("Age", "HD")
)

What if we have two continuous variables we allow to interact?

TODO: present data

What if we have two continuous variables we allow to interact?

\[ μ_i = α + β_xx_i + β_zz_i + β_{xz}x_iz_i \]

Change in Y per unit change in x

\[ \frac{\partial μ}{\partial x} = β_x + β_{xz}x \]

Change in Y per unit change in x

\[ \frac{\partial μ}{\partial z} = β_z + β_{xz}z \]

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!

We can center the variables, but it’s not enough:

output of summary of non-center

output of summary of center

Triptych plotting

explain

Water on shade

Distribution of BMI.

Number of those with glycemia.

BMI and glycemia, side by side.

Shade on water

Distribution of BMI.

Number of those with glycemia.

BMI and glycemia, side by side.

Non-linear model from interaction only

Show example where at a certain point, the variable doesn’t have an effect anymore… E.g., when patient has too low functioning, therapy doesn’t work anymore!

What about logistic regression?

To determine what the interaction means for your outcome, evaluate the interaction coefficient’s mathematical sign:

  • Positive Interaction (β₃ > 0):
    • The combined effect of both variables is greater than the sum of their individual effects. In terms of odds, the effect of X₁ is amplified as X₂ increases.
  • Negative Interaction (β₃ < 0):
    • The combined effect is less than the sum of their individual effects. The effect of X₁ is dampened or diminishes as X₂ increases.

What about logistic regression?

Differing Interpretations

  • Log-Odds Scale: An interaction term here assesses whether the multiplicative effect of the odds of an outcome changes based on another variable
  • Probability Scale: An interaction term here assesses whether the combined effect of two variables is greater or smaller than the sum of their individual effects.

Interaction madness

3-way interaction ?

4-way interaction ?

10-way interaction ?

50-way interaction ?

Example of interaction madness

Genetics x environment

We believe that genes are expressed conditional on lived experiences:

  • Adverse Child Experiences (psychiatry)
  • Exposure to toxins/viruses (nervous system)
  • Availability to food (obesity)

Intro to exercises:

Dataset….

Intro to exercises:

Code exercises are…

Plots are all available at website

Interpretation exercises are…