Skip to content

interaction draft#353

Open
tgerke wants to merge 26 commits intomainfrom
interaction
Open

interaction draft#353
tgerke wants to merge 26 commits intomainfrom
interaction

Conversation

@tgerke
Copy link
Copy Markdown
Collaborator

@tgerke tgerke commented Nov 19, 2025

draft of interaction and effect modification chapter

@tgerke
Copy link
Copy Markdown
Collaborator Author

tgerke commented Nov 19, 2025

ready for review! Obviously make any and all suggestions/revisions you see fit. I know we've debated over the years about how interactions should/should not be embedded in DAGs, so I tried to take the most neutral possible stance and cover what I think are the most common approaches.

@github-actions github-actions bot temporarily deployed to pull request November 19, 2025 02:02 Inactive
@malcolmbarrett
Copy link
Copy Markdown
Member

One big thing here is that I want to cover marginaleffects for interaction

@malcolmbarrett
Copy link
Copy Markdown
Member

ready for review! Obviously make any and all suggestions/revisions you see fit. I know we've debated over the years about how interactions should/should not be embedded in DAGs, so I tried to take the most neutral possible stance and cover what I think are the most common approaches.

Love this part of the chapter. Very nice display of the options

@malcolmbarrett
Copy link
Copy Markdown
Member

malcolmbarrett commented Nov 21, 2025

Another couple of things I'd like to see in this chapter:

  1. we need an example from our dataset. Maybe ticket season * extra magic morning? I think a good way to look at this would be to keep your simulated walkthrough then put this at the end and consider the question from the functional form vs. effect modification vs. joint cause approach. Like take the same model and consider how we would use it for all three approaches depending on our opinion on the structure/causal question
  2. At this point, we have covered g-computation, too, so related to @LucyMcGowan's chapter, I'd like to see a discussion of that (also related to my marginaleffects comment). You also say we are going to!

Copy link
Copy Markdown
Member

@malcolmbarrett malcolmbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for getting this in! lots of good, nuanced content here.

I've requested some additional changes in addition to my comments in the thread

In effect modification, we're interested in how the effect of E changes depending on Q.
In this setting, we condition on Q to look at what happens within levels of Q, but we don't necessarily intervene on Q itself.
Effect modification is asymmetric: it focuses on the effect of E, not on the effect of Q.
Importantly, Q must be a pre-treatment variable which cannot be affected by E [@hernan2021].
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should clarify here that this difference in effects IS due to the causal structure (we think) --- we just don't think it's due to the effect modifier. Like, SOMETHING is interacting in the causal sense to create this difference, but we are not, as you say, intervening on Q because we don't think that's it.

Relatedly, does it make sense to think about this approach when Q IS a joint cause BUT not practical to intervene on?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later on this is covered in depth, but we should still give a little taste here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malcolmbarrett I added a sentence addressing this above if you want to take a look

### Formal definitions

Let's make these concepts more precise using counterfactual notation.
Let $D_e$ denote the counterfactual outcome D under an intervention to set exposure E to level e.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a lot of inconsistency with what is being LaTexified here. I'm not sure what my opinion is about that, but I wanted to bring it up as a point of discussion

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Maybe this needs a full pass throughout the book, though

$$E[D_{e_1 q_1}] - E[D_{e_1 q_0}] \neq E[D_{e_0 q_1}] - E[D_{e_0 q_0}]$$

The two formulations are mathematically equivalent and show that E and Q have equal status in the definition of interaction [@hernan2021].
Like effect modification, interaction can be defined with respect to distributions or specific measures, and the presence of interaction may depend on the scale chosen (additive vs. multiplicative) [@VanderWeele2012; @VanderWeele2014].
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to see a callout box giving the intuition as to why we see interaction or not differently on different scales

For women (sex = 0), the effect of medication is `r round(coef(mod_em)[2], 2)` mmHg.
For men (sex = 1), the effect is `r round(coef(mod_em)[2] + coef(mod_em)[4], 2)` mmHg (`r round(coef(mod_em)[2], 2)` + `r round(coef(mod_em)[4], 2)`).

If we assume that medication is not affected by sex (which is true since sex precedes medication in time) and that the effect of medication on blood pressure is unconfounded given sex, then this interaction term measures effect modification; i.e., the effect of medication varies across levels of sex.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the statement about sex preceding medication in time, should this say "If we assume that sex is not affected by medication"?

filter(str_detect(term, "exercise|diet"))
```

The interaction term `exercise:diet` is `r round(coef(mod_interaction)[4], 2)`, suggesting that the joint effect of exercise and diet together is greater than the sum of their individual effects.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you've got the wrong coef here because this is rounding to 5 but the table says 2.79

The interaction term `exercise:diet` is `r round(coef(mod_interaction)[4], 2)`, suggesting that the joint effect of exercise and diet together is greater than the sum of their individual effects.
If we've correctly controlled for confounding of both exercise and diet, this coefficient measures interaction.

### Marginal structural models
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section, can you try to use propensity for the weights where possible? Where it is not possible please let me know so I can implement it


### Marginal structural models

**Marginal structural models (MSMs)** provide a framework for distinguishing between effect modification and interaction in the analysis [@VanderWeele2009].
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we need a callout box for the term marginal structural models which is used to refer to many techniques, presumably because it is a generalization of them (but I haven't thought it through or looked into usage all that much)


For interaction, we need weights for both E and Q:
$$w^E = \frac{P(E = e | Q = q)}{P(E = e | Q = q, X = x)}$$
$$w^Q = \frac{P(Q = q)}{P(Q = q | X = x)}$$
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need some intuition here, given the symmetric nature of interaction you lay out, about why we have

$$w^Q = \frac{P(Q = q)}{P(Q = q | X = x)}$$

and not

$$w^Q = \frac{P(Q = q)}{P(Q = q | E = e, X = x)}$$

@malcolmbarrett
Copy link
Copy Markdown
Member

Having slept on this, here are a few more things I wanted to include in this chapter:

Reviewing my notes on this chapter, I also found https://www.the100.ci/2024/06/26/sometimes-a-causal-effect-is-just-a-causal-effect-regardless-of-how-its-mediated-or-moderated/ which you might find as an interesting perspective

Copy link
Copy Markdown
Collaborator

@LucyMcGowan LucyMcGowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I started this review but I have general questions about terminology -- I don't think effect modification is necessarily in the absence of confounders? I think of effect modification just meaning is the effect modified by a particular variable (i.e. do we observe a different effect in different strata, these could be after conditioning on confounders) and interaction (as it seems like it is defined in the beginning of this chapter) to mean is it causal i.e. is Q actually the cause of the difference we see (vs. some other variable that is just correlated with Q) -- but then in the simulation it seems like we've moved away from those definitions (@tgerke do you mind weighing in?)


**Effect modification** occurs when the effect of one exposure (E) on an outcome (D) varies across strata of a third variable (Q).
In effect modification, we're interested in how the effect of E changes depending on Q.
In this setting, we condition on Q to look at what happens within levels of Q, but we don't necessarily intervene on Q itself.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this setting, we condition on Q to look at what happens within levels of Q, but we don't necessarily intervene on Q itself.
In this setting, we condition on Q to look at what happens within levels of Q, but we don't necessarily intervene on Q itself. We are not necessarily claiming that Q is the cause of the observed heterogeneity. While the difference in effects across levels of Q is likely causal in origin (something in the underlying causal structure produces this variation), Q may just be a correlate or marker of that causal factor rather than the factor itself.

Copy link
Copy Markdown
Collaborator

@LucyMcGowan LucyMcGowan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I started this review but I have general questions about terminology -- I don't think effect modification is necessarily in the absence of confounders? I think of effect modification just meaning is the effect modified by a particular variable (i.e. do we observe a different effect in different strata, these could be after conditioning on confounders) and interaction (as it seems like it is defined in the beginning of this chapter) to mean is it causal i.e. is Q actually the cause of the difference we see (vs. some other variable that is just correlated with Q) -- but then in the simulation it seems like we've moved away from those definitions (@tgerke do you mind weighing in?)

@LucyMcGowan
Copy link
Copy Markdown
Collaborator

(I made a bunch of switchings of E->X, D->Y and am just committing those but I'll leave the rest as suggestions for you to look through

Co-authored-by: Lucy D'Agostino McGowan <LucyMcGowan@users.noreply.github.com>
Co-authored-by: Lucy D'Agostino McGowan <LucyMcGowan@users.noreply.github.com>
Co-authored-by: Lucy D'Agostino McGowan <LucyMcGowan@users.noreply.github.com>
Co-authored-by: Lucy D'Agostino McGowan <LucyMcGowan@users.noreply.github.com>
Co-authored-by: Lucy D'Agostino McGowan <LucyMcGowan@users.noreply.github.com>
@tgerke
Copy link
Copy Markdown
Collaborator Author

tgerke commented Mar 26, 2026

Ok I started this review but I have general questions about terminology -- I don't think effect modification is necessarily in the absence of confounders? I think of effect modification just meaning is the effect modified by a particular variable (i.e. do we observe a different effect in different strata, these could be after conditioning on confounders) and interaction (as it seems like it is defined in the beginning of this chapter) to mean is it causal i.e. is Q actually the cause of the difference we see (vs. some other variable that is just correlated with Q) -- but then in the simulation it seems like we've moved away from those definitions (@tgerke do you mind weighing in?)

This is a good catch -- the chapter could be more clear here. Effect modification is definitely not limited to settings without confounders, and we can and should adjust for confounders of E->D effect when assessing effect modification. But what matters is the role of Q: in effect modification, Q is a conditioning variable, not an intervention target (which would be interaction).

These definitions are very much motivated by VanderWeele 2009 which was drilled into my head during training, but we don't have to stick with those if there's a better way to frame how we like to call things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants