How to do within group comparisons without subsetting data

by Parseltongue   Last Updated August 13, 2019 22:19 PM

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?

Tags : r mediation


Related Questions


Updated April 22, 2015 01:08 AM

Updated April 28, 2015 03:08 AM

Updated May 26, 2015 03:08 AM

Updated August 08, 2015 14:08 PM

Updated August 09, 2015 17:08 PM