I'm starting to get a little confused about how R knows which variable is the main variable and which others are simply controls. For example, let's say there are three variables Y, X1, and X2, and I'm mainly interested in X1. I regress Y = constant + X1 + X2 + error. The function of X2 is to block any indirect effect that can confound the true relationship between Y and X1, such as in the diagram below. However, the coefficients and standard errors are probably going to be the exact same if we run Y = constant + X2 + X1 + error. So does that mean the coefficient that R calculates for X1 and X2 are already taking into account that both could influence each other regardless of what the main variable is?
Asked
Active
Viewed 70 times

lm, you will get the same results. I would also like to note that you would test a mediation model using separate regression equations. See this question. – T.E.G. Apr 02 '23 at 05:36