# How to model whether differences in two variables vary across the levels of a third variable?

Say we have a variable A (some interaction network metric, continuous, N=20), and we want to see if A varies across B (categorical variable, 2 levels) depending on the levels of a third categorical variable C (3 levels).

So I am interested in exploring whether the differences in my interaction network metrics (A) vary across environmental gradients (B), depending on the way I measure it (C) (i.e. Do I get different results regarding differences to environmental gradient depending on the way y measure it?).

An interaction model tells me the differences between every condition (every level combination) but I just want to know the differences of A against B conditional to the three C levels.

Another option is to calculate the differences between A and B, and use it as the dependent variable to build a model.

Is there another way to model this relationship with the raw data so that I do not have to calculate a new variable?

• Is there any reason you don't want to calculate the difference $B-A$? Maybe you want a symmetric analysis? There are many possibilities, can you tellus what this variables represent in real life? Commented Jan 27, 2019 at 15:05
• Your direct approach makes the most sense to me!
– user233429
Commented Jan 27, 2019 at 15:28
• Thank you for your help. I am sorry I made a mistake when I wrote the question (I eddited it). If I calculate the differences before, I think I am losing information. I will only have 10 samples instead of 20 and I will modify the distribution of the errors as far as I know. Commented Jan 28, 2019 at 21:01

Meanwhile, you should start by making some plots (and show us). Since $$C$$ is categorical, in practice this could depend on the number of levels of $$C$$ (one reason we need some context and not only a very abstract problem description.) For the time being assuming not to many levels, some possibilities:
In case your two measurements $$A,B$$ is pre- and post some intervention or similar, see Best practice when analysing pre-post treatment-control designs