##### Demonstration Script #6a ##### MATH322 ##### ##### A quick ANOVA example in R ##### ### Illustrate multicollinearity # and its issue X = matrix( c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1), ncol=5 ) det( t(X)%*%X ) solve( t(X)%*%X ) ### Doing ANOVA in R y = c(6,2,9,8,2,3,7,3,8,7,7,9,6,4,6,3) x = c("A","A","A","A", "B","B","B","B", "C","C","C","C", "D","D","D","D" ) # one can also do x = c( rep("A",4), rep("B",4), rep("C",4), rep("D",4) ) # To get effects model mod = aov(y~x) summary(mod) # F-test for yield variable effect summary.lm(mod) # t-tests for variety effects as compared to tau A # To get means model mod2 = aov(y~x+0) summary(mod2) # Actually meaningless F-test for mean(data)=0 summary.lm(mod2) # What do these estimates estimate?