Skip to main content
4 of 6
added 1479 characters in body
Parseltongue
  • 1.1k
  • 2
  • 11
  • 28

How to do within group moderation analysis without subsetting data

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 X.

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?


Edit: Ran the nested specification suggested by @cdtip and it resulted in the following output:

             Estimate Std. Error  t value  Pr(>|t|) CI Lower CI Upper  DF
(Intercept)   -1.33113   4.96200 -0.26826 0.7889642 -11.1572  8.49498 118
treatmentC    -5.90437   6.94422 -0.85026 0.3969036 -19.6558  7.84706 118
treatmentB    24.92750   9.27155  2.68860 0.0082136   6.5673 43.28769 118
treatmentA    7.26947    5.73785  1.26693 0.2076739  -4.0930 18.63197 118
treatmentD:X  0.65245    1.27021  0.51366 0.6084530  -1.8629  3.16782 118
treatmentC:X  5.15284    1.64776  3.12717 0.0022231   1.8898  8.41586 118
treatmentB:X -2.65812    1.08513 -2.44959 0.0157709  -4.8070 -0.50927 118
treatmentA:X -0.69822    0.67031 -1.04163 0.2997141  -2.0256  0.62919 118

I'm somewhat unclear how to interpret this. The coefficient on treatmentC:X is 5.15 and significant. But it seems like it's significant relative to the left out condition which is treatmentD, rather than making a within treatment comparison. How am I supposed to interpret these results?

It seems like the / operator is just shorthand for:

lm(outcome ~ treatment + treatment:x)

(so removing the main effect of X).

I have found references to "subgroup analysis" and "heterogeneous treatment effect", but these seem to refer to a singular treatment condition, in which the size of the effect varies by some moderator.


Final Edit:

                                 Estimate Std. Error  t value  Pr(>|t|)  CI Lower CI Upper  DF
treatmentA                       -1.33113    4.96200 -0.26826 0.7889642 -11.15724  8.49498 118
treatmentB                       -7.23550    4.85805 -1.48938 0.1390545 -16.85577  2.38477 118
treatmentC                       23.59638    7.83199  3.01282 0.0031679   8.08690 39.10586 118
treatmentD                        5.93834    2.88122  2.06105 0.0414956   0.23274 11.64395 118
treatmentA :moderator             0.65245    1.27021  0.51366 0.6084530  -1.86291  3.16782 118
treatmentB :moderator             5.15284    1.64776  3.12717 0.0022231   1.88982  8.41586 118
treatmentC :moderator            -2.65812    1.08513 -2.44959 0.0157709  -4.80698 -0.50927 118
treatmentD :moderator            -0.69822    0.67031 -1.04163 0.2997141  -2.02562  0.62919 118

I'm a little confused on how to interpret the interaction effects. It looks like, for treatment B, every additional increase in the moderator value increases the outcome by 5. However, the main effect of treatment B is -7.2. Meanwhile, the effect of the moderator on treatment C is negative (-2.6), but the main effect is large and positive (23.59). As a result, the interaction terms on treatmentC may be misleading because it's unlikely that the combined effect of the moderator + treatment will ever be overall negative. Is there a way to characterize this nuance?

Parseltongue
  • 1.1k
  • 2
  • 11
  • 28