# Linear Regression and ANOVA [duplicate]

I found two very useful posts about the difference between linear regression analysis and ANOVA and how to visualise them:

Why is ANOVA taught / used as if it is a different research methodology compared to linear regression?

How to visualize what ANOVA does?

As stated in the first post, to test whether the average height of male and females is the same you can use a regression model ($y = \alpha + \beta x + \epsilon$, where $y$ denotes height and $x$ denotes gender) and test whether $\beta = 0$. If $\beta = 0$, then there is no difference in the height between males and females. However, I am not quite sure how this is tested when you have three groups. Imagine the following example:

height (y) -  group (x)
5          -  A
6          -  A
7          -  A
6          -  A
30         -  B
32         -  B
34         -  B
33         -  B
20         -  C
19         -  C
21         -  C
22         -  C


The regression model would look like:

$$y = a+ b x + \epsilon$$

I quickly visualized the data (see image below)

They way I understood the regression model is that it would now test whether any of the three slopes (AB, AC or BC) has a slope $b$ which is significantly different from 0. If that's the case one can conclude like in an ANOVA that there is at least one group in which height is significantly different from one or more groups. Afterwards, one could use a post-hoc test of course to test which of the groups really differ. Is my understanding of how the regression models tests this hypothesis correct?

• If A, B and C are separate groups (not levels of a continuous variable) then you can't really draw lines between them, or place them equidistant on the x-axis. – Peter Flom Jul 14 '13 at 11:13

For categorical $X$ it is better to think of contrasts and group differences. Visualization per se doesn't help get this idea across, I think, other than to nicely show confidence limits in addition to point estimates of differences in means.
I do find that I almost never use ANOVA, in favor of linear models, except when I want to partition the sum of squares due to regression to describe, for example, how much of the variation in $Y$ is due to nonlinear effects in $X$ or is due to a subset of $X$s.