R

anova

More notes

Posted by Shsun on January 16, 2020

ANOVA table gives the significance of the overall model. ANOVA is a statistical process first derived by R. A. Fisher in 1925.

The anova() function call returns an ANOVA table.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
> PC.reg = lm(Y.n ~ -1 + PC1 + PC2 + PC3 + PC4 + PC5, na.action=na.exclude)
> anova(PC.reg)
Analysis of Variance Table

Response: Y.n
           Df Sum Sq Mean Sq F value    Pr(>F)    
PC1         1  64.47  64.472 78.6426 < 2.2e-16 ***
PC2         1   7.56   7.556  9.2169 0.0024664 **
PC3         1   4.44   4.436  5.4110 0.0202300 *  
PC4         1  81.74  81.743 99.7092 < 2.2e-16 ***
PC5         1   9.23   9.227 11.2549 0.0008271 ***
Residuals 907 743.57   0.820                      
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

The function confint is used to calculate confidence intervals on the treatment parameters, by default 95% confidence intervals.

1
2
3
4
5
6
7
> confint(PC.reg)
         2.5 %    97.5 %
PC1 0.12730735 0.1996705
PC2 0.02211786 0.1030011
PC3 0.01113563 0.1313582
PC4 0.26906828 0.4007092
PC5 0.05378127 0.2054072

There are three types of sum of squares in anova output. Consider a model that includes two factors A and B; there are two main effects and an interaction, AB. The full model is represented by SS(A, B, AB). The influence of factors and interactions can be tested by examining difference between models. For example, to test the interaction effect, we can do a F-test of model SS(A, B, AB) and model SS(A, B)

1
2
3
4
5
SS(AB | A, B) = SS(A, B, AB) – SS(A, B)
SS(A | B, AB) = SS(A, B, AB) – SS(B, AB)
SS(B | A, AB) = SS(A, B, AB) – SS(A, AB)
SS(A | B) = SS(A, B) – SS(B)
SS(B | A) = SS(A, B) – SS(A)
The notation shows the incremental differences in sums of squares, for example SS(AB A, B) represents “the sum of squares for interaction after the main effects”, and SS(A B) is “the sum of squares for the A main effect after the B main effect and ignoring interactions”.
Reference
  1. Anova - Type I/II/III SS explained