I am supposed to check the significance of the connection between an arbitary Y variable (nominal\ordinal\binary I cannot know in advance) and an arbitary numeric X variable.

This is a classification problem. However may I just flip the Y and X variables to make the problem simpler and use ANOVA? Instead of Y~X, just X~Y?

in the following post I see the slope of the line changes if we swap Y~X to X~Y. I wonder if it also applies to ANOVA. or effect the goodness of fit: Effect of switching response and explanatory variable in simple linear regression

when I do a little test (am variable is binary):

mydata <- mtcars

summary(lm(am~mpg,data = mydata))

summary(lm(mpg~am,data = mydata))

the F statistic for both regressions is the same.

enter image description here


  • 1
    $\begingroup$ Hi and welcome to CV! The two approaches serve different purposes and need different assumptions. $\endgroup$
    – utobi
    Commented Sep 12, 2023 at 8:02
  • $\begingroup$ sure does! but I only wish to assesss the strengh of the connenction, nothing more. $\endgroup$
    – amann
    Commented Sep 12, 2023 at 8:53
  • 1
    $\begingroup$ Welcome to Cross Validated! Why don’t you know the type of $y$ variable you will be getting? // It has been argued that it is advantageous to model the categorical outcome. $\endgroup$
    – Dave
    Commented Sep 12, 2023 at 10:30
  • $\begingroup$ @Dave, actually I can get the following information on the y variable- number of categories (binary, multiclass). I do not know the order (even if defined it might be defined out of ggplot needs and not relate to actual ordinal levels). My issue is mostly with the multiclass situation $\endgroup$
    – amann
    Commented Sep 12, 2023 at 10:57

1 Answer 1


The correlation between $X$ and $Y$ is the same as the correlation between $Y$ and $X$, and this extends to some other summaries. As you note, the usual test statistic is the same. The slopes are the same if the variables are scaled to have the same variances (eg, if they are scaled to have unit variance). Since the slopes are the same, their standard errors are the same.

This fact isn't useful very often, since usually you should just fit the model the right way around, but it is useful sometimes. In particular, if you want to fit a lot of regression models with the same outcome but different predictors, it can occasionally be computationally useful to work with the reverse model that has the same predictor and lots of different outcomes.


Your Answer

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

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