I am trying to evaluate the relationship between two variables - x and y. Variable x has a number of known covariates: a, b, and c. I have identified how these covariates are related to x in r with the formula:
lm(x ~ a + b + c)
How do I adjust x such that I can plot a regression line for y ~ x?
I apologize if this is a simple question - everywhere that I look the answers to this question are to adjust it in the linear model itself by adding the covariates as terms (e.g. y ~ x + a + b + c). This does not seem right to me because while y may or may not covary with a, b, and c, I am only interested in controlling for the impact these have on x. Am I missing something conceptually? How can I do this in r?
y ~ a+ b+ cagainstx ~ a +b+ c. Alternately, you can create some ranges values of [a, b, c] and plot the bivariate y ~ x relation in a grid among those ranges (see?coplotin R for some motivating examples). – AdamO Oct 28 '22 at 20:33y ~ w, wherewisxadjusted fora, b, c. But how would you know how to make this adjustment ? You could use some theoretical or empirical understanding of howx, a, b, ccould be combined intow. Or, I think, you would usey ~ x + a + b + c, and look at the predicted values from that regression. That would be the best combination ofx, a, b, cto predictygiven the constraints of the chosen model. – Sal Mangiafico Oct 28 '22 at 22:44y ~ x + a + b + cwould work for this? – womy Oct 28 '22 at 22:51