[R] lm type of sums of squares

Liaw, Andy andy_liaw at merck.com
Fri Oct 28 19:25:18 CEST 2005


anova.lm() gives the sequential tests:

> set.seed(1)
> dat <- data.frame(y=rnorm(10), x1=runif(10), x2=runif(10))
> anova(lm(y ~ x1 + x2, dat))
Analysis of Variance Table

Response: y
          Df Sum Sq Mean Sq F value Pr(>F)
x1         1 1.1483  1.1483  2.0943 0.1911
x2         1 0.4972  0.4972  0.9068 0.3727
Residuals  7 3.8383  0.5483               
> anova(lm(y ~ x2 + x1, dat))
Analysis of Variance Table

Response: y
          Df Sum Sq Mean Sq F value Pr(>F)
x2         1 0.5165  0.5165  0.9419 0.3641
x1         1 1.1291  1.1291  2.0592 0.1944
Residuals  7 3.8383  0.5483               

The SS, F-stat, etc. would be invariant to order only if the terms are
orthogonal.


Andy


> From: Jarrett Byrnes
> 
> I'm curious, I realize there are methods for Type II and III sums of 
> squares, and yet, when I've been constructing models with lm, I've 
> noticed that position of the term of the model has not mattered in 
> terms of its p-value.  Does lm use sequential Type I sums of squares, 
> or something else?
> 
> Thanks!
> 
> -Jarrett
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list