# [R] Difference between two-way ANOVA and (two-way) ANCOVA

peter dalgaard pdalgd at gmail.com
Wed Jul 4 15:53:21 CEST 2012

```On Jul 4, 2012, at 15:20 , syrvn wrote:

> Hi!
>
> as my subject says I am struggling with the different of a two-way ANOVA and
> a (two-way) ANCOVA.
>
> I found the following examples from this webpage:
>
> http://www.statmethods.net/stats/anova.html
>
> # One Way Anova (Completely Randomized Design)
> fit <- aov(y ~ A, data=mydataframe)
>
> # Randomized Block Design (B is the blocking factor)
> fit <- aov(y ~ A + B, data=mydataframe)
>
> # Two Way Factorial Design
> fit <- aov(y ~ A + B + A:B, data=mydataframe)
> fit <- aov(y ~ A*B, data=mydataframe) # same thing
>
> # Analysis of Covariance
> fit <- aov(y ~ A + x, data=mydataframe)
>
> I) The 1. example is pretty clear. A simple on way ANOVA.
>
> II) Is it correct to say that example 2. (which is called a Randomized Block
> Design) is a two way ANOVA?
>
> III) Example 3 is like example 2. (in case I was right in II) )  a two way
> ANOVA but including an interaction term. That's why
> they call it here a Factorial Design.
>
> So far so good.
>
> IV) For me, the ANCOVA (last example) looks like a two-way ANOVA. So in what
> way is the variable "x" different to variable "B" so that it is called an
> ANCOVA and not an ANOVA??? I presume that from the type of data R knows
> whether to perform an ANCOVA or an ANOVA.
>
> V) Is it right to say that the ANCOVA example is a two-way ANCOVA? Or can a
> one-way ANCOVA actually exists?
>
> You see I am a bit confused especially how R distinguishes between the
> ANCOVA and the two-way ANOVA?
>
> I hope to find some useful answers here.

Well, it's not really about R, is it?

Anyways, I'd call  y~A+x a ONE-way ANCOVA, because it deals with the covariation of two variables (y and x) in a one-way layout. In the traditional applications, x is often independent of A (pre-randomization measurement like soil quality, etc.) so that the group means of y can be estimated as the value of the regression at the grand mean of x ("adjusted means"), and the mean difference between two groups is the vertical difference between the parallel regression lines.

>
> Cheers!
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Difference-between-two-way-ANOVA-and-two-way-ANCOVA-tp4635403.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help