{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 11_06 - factor(A 1 168.0 168.0 1.5667 0.222743 factor(B 2...

This preview shows pages 1–3. Sign up to view the full content.

STAT 420 Examples for 11/06/2007 Fall 2007 Factor B Factor A 1 2 3 1 56 23 52 28 35 43 25 16 27 32 47 43 52 61 74 2 16 14 18 27 31 58 62 68 72 83 15 14 22 16 27 Means: Factor B Factor A 1 2 3 1 38.8 28.6 55.4 40.93333 2 21.2 68.6 18.8 36.2 30 48.6 37.1 38.56667

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> Y <- c(56, 23, 52, 28, 35, 43, 25, 16, 27, 32, 47, 43, 52, 61, 74, + 16, 14, 18, 27, 31, 58, 62, 68, 72, 83, 15, 14, 22, 16, 27) > A <- c( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) > B <- c( 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3) > results <- aov(glm(Y ~ factor(A) * factor(B))) > summary(results) Df Sum Sq Mean Sq F value Pr(>F)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: factor(A) 1 168.0 168.0 1.5667 0.222743 factor(B) 2 1762.1 881.0 8.2148 0.001915 ** factor(A):factor(B) 2 7955.3 3977.6 37.0875 4.555e-08 *** Residuals 24 2574.0 107.2 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > # Cell means > tmp <- NULL > for(a in 1:2) + { + for(b in 1:3) + { + tmp <- c(tmp,mean(Y[A==a & B==b])) + } + } > means <- matrix(tmp,nrow=2,byrow=TRUE) > tmp [1] 38.8 28.6 55.4 21.2 68.6 18.8 > means [,1] [,2] [,3] [1,] 38.8 28.6 55.4 [2,] 21.2 68.6 18.8 > # for 2 plots on the same page > par(mfrow=c(1,2)) > > plot(Y~A,col=B,pch=B) > for(b in 1:3) + { + lines(1:2,means[,b],col=b) + } > > plot(Y~B,col=A,pch=A) > for(a in 1:2) + { + lines(1:3,means[a,],col=a) + }...
View Full Document

{[ snackBarMessage ]}