[R] Extra Sums of Squares from an anova table - why are the values different?

Stephen Sefick ssefick at gmail.com
Wed Oct 26 20:19:06 CEST 2011


#For full disclosure- I am working on a homework problem.  However, my 
question revolves around computer rounding, I think.


x <- (structure(list(y = c(0.222, 0.395, 0.422, 0.437, 0.428, 0.467,
0.444, 0.378, 0.494, 0.456, 0.452, 0.112, 0.432, 0.101, 0.232,
0.306, 0.0923, 0.116, 0.0764, 0.439, 0.0944, 0.117, 0.0726, 0.0412,
0.251, 2e-05), x1 = c(7.3, 8.7, 8.8, 8.1, 9, 8.7, 9.3, 7.6, 10,
8.4, 9.3, 7.7, 9.8, 7.3, 8.5, 9.5, 7.4, 7.8, 7.7, 10.3, 7.8,
7.1, 7.7, 7.4, 7.3, 7.6), x2 = c(0, 0, 0.7, 4, 0.5, 1.5, 2.1,
5.1, 0, 3.7, 3.6, 2.8, 4.2, 2.5, 2, 2.5, 2.8, 2.8, 3, 1.7, 3.3,
3.9, 4.3, 6, 2, 7.8), x3 = c(0, 0.3, 1, 0.2, 1, 2.8, 1, 3.4,
0.3, 4.1, 2, 7.1, 2, 6.8, 6.6, 5, 7.8, 7.7, 8, 4.2, 8.5, 6.6,
9.5, 10.9, 5.2, 20.7), x11 = c(53.29, 75.69, 77.44, 65.61, 81,
75.69, 86.49, 57.76, 100, 70.56, 86.49, 59.29, 96.04, 53.29,
72.25, 90.25, 54.76, 60.84, 59.29, 106.09, 60.84, 50.41, 59.29,
54.76, 53.29, 57.76), x22 = c(0, 0, 0.49, 16, 0.25, 2.25, 4.41,
26.01, 0, 13.69, 12.96, 7.84, 17.64, 6.25, 4, 6.25, 7.84, 7.84,
9, 2.89, 10.89, 15.21, 18.49, 36, 4, 60.84), x33 = c(0, 0.09,
1, 0.04, 1, 7.84, 1, 11.56, 0.09, 16.81, 4, 50.41, 4, 46.24,
43.56, 25, 60.84, 59.29, 64, 17.64, 72.25, 43.56, 90.25, 118.81,
27.04, 428.49), x12 = c(0, 0, 6.16, 32.4, 4.5, 13.05, 19.53,
38.76, 0, 31.08, 33.48, 21.56, 41.16, 18.25, 17, 23.75, 20.72,
21.84, 23.1, 17.51, 25.74, 27.69, 33.11, 44.4, 14.6, 59.28),
     x13 = c(0, 2.61, 8.8, 1.62, 9, 24.36, 9.3, 25.84, 3, 34.44,
     18.6, 54.67, 19.6, 49.64, 56.1, 47.5, 57.72, 60.06, 61.6,
     43.26, 66.3, 46.86, 73.15, 80.66, 37.96, 157.32), x23 = c(0,
     0, 0.7, 0.8, 0.5, 4.2, 2.1, 17.34, 0, 15.17, 7.2, 19.88,
     8.4, 17, 13.2, 12.5, 21.84, 21.56, 24, 7.14, 28.05, 25.74,
     40.85, 65.4, 10.4, 161.46)), .Names = c("y", "x1", "x2",
"x3", "x11", "x22", "x33", "x12", "x13", "x23"), row.names = c(NA,
-26L), class = "data.frame")
)

x$x11 <- x$x1^2
x$x22 <- x$x2^2
x$x33 <- x$x3^2
x$x12 <- x$x1*x$x2
x$x13 <- x$x1*x$x3
x$x23 <- x$x2*x$x3

x.lm <- lm(y~x1+x2+x3+x11+x22+x33+x12+x13+x23, data=x)

anova(lm(y~x1+x2+x3,data=x), x.lm)

anova(x.lm)

#I want to test

#Ho:y~x1+x2+x3
#Ha:y~x1+x2+x3+x11+x22+x33+x12+x13+x23

((0.00945+0.01340+0.00200+0.00568+0.00489+0.00050)/6)/(0.00371)

#Thanks

#Stephen Sefick



More information about the R-help mailing list