# addressing the effect of the independent variable on the dependent variable for 2 different types of individuals

I am estimating the effect of a continous treatment X (that goes from 0 to 1) on a dependent variable y (data is taken through an experiment).

I have around 250 Individuals in my dataset that can be divided in two, depending on another variable (50 in group 1 and 200 in group). I want to test if the effect of X on Y varies depending on the group to which the individual belongs

so i developed this model

where D is a dummy variable stating if individual i belongs to group 1 and group 2. So basically multiplying x for D I can obtain estimates of of the coefficient of x separately. Finally I performed an F-test to show that B1 and B2 are different from one another. Does it sound right to you? Alternatively, I could run the equation separately for the two groups but I obtain very similar results and the two groups are quite unbalanced..

• What is opinion in the model? – user158565 Aug 2 at 16:14
• @user158565 it s avariable I used to split individuals in two groups, for opinion <0 they are in group 1, for opinion >0 they are in group 2 – Carbo Aug 3 at 11:19

Let $$D_i=1$$ if individual $$i$$ is in group 1, = 0 if in group 2. In can fit the model $$Y_i = \beta_0 + \beta_1D_i +\beta_2X_i + \beta_3X_iD_i + \beta_4 Z_i +\epsilon$$ where $$Z_i=$$ opinion.

By this model, you fit two lines for group 1 and 2. For group 1, $$E(Y)= \beta_0 + \beta_2X_i +\beta_4 Z_i$$ For group 2 you have, $$E(Y) = (\beta_0 + \beta_1) + (\beta_2 + \beta_3)X_i + \beta_4 Z_i$$ So if the effect of X on Y varies depending on the group to which the individual belongs is determined by if $$\beta_3 = 0$$. So testing the null hypothesis $$H_0: \beta_3=0$$ to achieve your goal.

Note 1: $$\beta_1D_i$$ should be included in the model, given $$\beta_3D_iX_i$$ exist in the model, even test shows that $$\beta_1 = 0$$ is acceptable (high p value).

Note 2: "run the equation separately for the two groups" is bad idea, because it is hard to test if two lines have the same slope.

Note 3:if "the two groups are quite unbalanced" means the numbers of individuals have big difference (50 vs 150) in two groups, then you do not need to worry about it. We concern the number of individuals in the smaller group. If one group just have 5 individuals, the reliability of fitted model is very low. In your situation, 50 individuals should be OK.

• thank you very much for your exhaustive explanation! I just have one minor doubt, If I expect the effect for one of the groups to be negative and the effect for the other group to be positive, wouldn't your model make it difficult to see? I mean that B2 would tend to 0 and I would see the directionality of the effect just for group 2 thanks to B3. am I wrong? – Carbo Aug 4 at 10:21
• Does your "effect" mean the slop of $X_i$, which is $\beta_2$ for group 1 and $\beta_2+\beta_3$ for group 2? – user158565 Aug 4 at 17:32

Your current procedure seems right to me, but you could make it even simpler by considering:

$$Y = \gamma_1 X + \gamma_2 X * D_2 + (...)$$

As you only have 2 groups, $$\gamma_2$$ will be significantly positive only if the specific effect of X on Y is higher for group 2.

Ps: Note that you might also be interested to have in the equation group fixed-effect $$T_1$$ ?

• Thank you for your feedback, I inserted a sort of group fixed effect with the variable opinion, groups are based on the variable opinion, if opinion is <0 they are in group 1, while if opinion is >0 they are in group 2, So i decided to keep it continuous, I hope it makes sense – Carbo Aug 3 at 11:18