I am running a regression test for which I overall have two variables (x and y) and I would like to test if any of them is dependent on the other.

y = ax + intercept

No matter which one of the variables is the dependent one, I get the same R-squared and p-values (either with Matlab or with Rstudio). Intercept and predictor coefficients do change according to which variable is the independent one, but R-squared and p-value don't. Why is this happening? Can anyone explain and/or add any relevant paper?

Thanks in advance!

  • 1
    $\begingroup$ In a simple linear regression (one predictor) like you have, $R^2 = cor(x, y)^2$. Since $cor(x, y) = cor(y, x)$, the $R^2$ does not change, either. $\endgroup$
    – Dave
    Jun 8, 2021 at 16:09
  • $\begingroup$ Thanks for your answer! I understand the maths but still this doesn't make sense to me. If y is dependent on x, then why is it equally possible that x is dependent on y? Isn't the null hypothesis in linear regression saying that y doesn't depend on x (the direction does matter)? While null hypothesis in correlation (e.g Pearson's) assumes that there isn't any kind of depency, no matter where it comes from... $\endgroup$ Jun 9, 2021 at 8:42

1 Answer 1


I will try to explain the intuition. In simple linear regression, you model association between x and y. Thus it is irrelevant if x explain y or y explain x. Either way the relation between the two is the same. Therefore you would expect to get the same R^2 and p-value no-matter the order.

  • $\begingroup$ Thanks for the explanation! $\endgroup$ Jun 9, 2021 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.