# R - using contrasts to compare all levels of a variable?

I am doing a statistical analysis in R. I made a lmer() model, in which a variable has 4 levels (1,2,3,4). The script sets up a contrast matrix for these levels. Basically, The main hypothesis is set up as:

Contrast:
4>3
4>2
4>1


As my study was exploratory, I was also curious of the remaining couples, and I "switched" the contrasts in order to get information about:

3>2
3>1
2>1


When I say that I "switched" the contrasts, I mean that I run the exactly same analysis by "substituting" some levels in the contrast matrix above. This because I noticed that different matrices didn't produce any change for the same contrasts, so I thought it didn't introduce any error.

Can I do that?

Best Luca

• Obviously, you can do what you are doing. The question is what you are doing with the result. If you are interested in p-values, you should only do the planned contrasts. May 6, 2019 at 14:11
• Thank you @Roland! Can you extend a little your explanation? I can understand that the acknowledged method is to do just the planned contrast, but I can't understand why. And I don't know what other alternative there are for a level-to-level comparison without going into post-hoc analysis. May 6, 2019 at 14:19
• stats.stackexchange.com/a/63668/11849 May 6, 2019 at 14:25
• @Roland, the explanation in the link you provided is only partially satisfying. The thing is that using a contrast between different groups, the analysis tells me what is the probability one group is going to perceive a difference between the two levels tested in comparison to another group. The classical post-hoc analysis (e.g. Tukey's correction) does not provide me with that information, and provides me only with the information of how those levels are perceived within one group. May 6, 2019 at 14:38
• To be clearer: I am interested to understand the differences in the levels of my aimed variable, depending on its interaction with other variables (groups, and others). May 6, 2019 at 14:41