Let's say I run the following regression specification:
lm(outcome ~ treatment)
Where treatment is a factor variable that can take four values
A, B, C, or D . I suspect that there is this predictor,
X that moderates the relationship between the treatment and the outcome. However, I don't really care about comparisons across treatment groups -- what I want to be able to say is that, within a given treatment (e.g.
A), people with high values of
X have better outcomes then individuals with low values of
What comes to mind is some kind of interaction effect like:
lm(outcome ~ treatment*X)
But that will only tell me how the treatment varies at different levels of X, in comparison to some left out reference group (rather than in comparison to the same treatment but low values of X).
What is the right way of going about doing this?