Skip to main content
Source Link

How is an ANOVA table calculated when using continuous predictors only?

An ANOVA can be described as a regression with dummy variables. You could for example calculate the sums of squares treatment in an ANOVA table using the coefficients from a linear model

> y <- rnorm(10)
> x1 <- as.factor(c(0,0,0,0,0,0,1,1,1,1))
> y.bar <- mean(y)
> f1 <- lm(y ~ x1)
> sum(((f1$coef[1]) - y.bar)^2)*6 + sum(((f1$coef[1] + f1$coef[2]) - y.bar)^2)*4
[1] 1.784887
> anova(f1)
Analysis of Variance Table

Response: y
          Df Sum Sq Mean Sq F value Pr(>F)
x1         1 1.7849  1.7849   1.596  0.242
Residuals  8 8.9470  1.1184

              

However, when using two or more continuous predictors

> x2 <- rnorm(10)
> x3 <- rnorm(10)
> f2 <- lm(y ~ x2 + x3)
> anova(f2)
Analysis of Variance Table

Response: y
          Df Sum Sq Mean Sq F value Pr(>F)
x2         1 0.7797 0.77970  0.5959 0.4654
x3         1 0.7934 0.79336  0.6064 0.4617
Residuals  7 9.1588 1.30841

How are sums of squares calculated and how could they be interpreted?