# anova - ANOVA Suppose X ={xij is an n × m matrix with...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ANOVA Suppose X = {xij } is an n × m matrix with numbers. In ANOVA we study the decomposition xij = µ + αi + βj + γij into a main eﬀect, a row eﬀect, a column eﬀect, and an interaction. We identify the decomposition by requiring n αi = 0, i=1 m β j = 0, j =1 n γij = 0 for all j, i=1 m γij = 0 for all i. j =1 Now write 1 xij , nm i=1 j =1 1 xij , m j =1 n m n m x•• = xi• = x•j 1 = xij . n i=1 Date: April 23, 2007. 1 2 ANOVA Then µ = x•• , αi = xi• − x•• , βj = x•j − x•• , γij = xij − xi• − x•j + x•• . Moreover n m n m (xij − µ) = i=1 j =1 n 2 (αi + βj + γij )2 = i=1 j =1 m n m 2 γij , i=1 j =1 =m i=1 α2 i +n j =1 β2 j + which we can write as SSQtotal = SSQr ow + SSQcolumn + SSQinter action , and also as 2 2 2 2 σ 2 χnm−1 = σ 2 {χn−1 + χm−1 + χ(n−1)(m−1) }. Source Rows Columns Interaction Total Sum of Squares Degrees of Freedom n SSQR = m i=1 α2 i m SSQC = n j =1 β2 j n m 2 SSQI = i=1 j =1 γij n m 2 i=1 j =1 (xij − µ) Mean Square 1 n−1 SSQR 1 m−1 SSQC n−1 m−1 (n − 1)(m − 1) nm − 1 1 (n−1)(m−1) SSQI ANOVA anova<−function ( x ) { n<−nrow ( x ) ; m −ncol ( x ) < mu) ^2) mu −mean ( x ) ; s t o t<−sum ( ( x− < alpha<−apply ( x , 1 , mean )−mu; srow<− *sum ( alpha ^2) m 5 beta<−apply ( x , 2 , mean )−mu; scol<−n *sum ( beta ^2) gamma<−x−outer ( alpha , beta , " + " )−mu; s i n t<−sum ( gamma^2) cat ( "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−\n" ) cat ( " 10 cat ( " Source | Sum of Squares | Degrees of Freedom | Mean Square\n" ) Rows" , formatC ( srow , d i g i t s =6 , width=16 , format= " f " ) , formatC ( n−1, cat ( "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−\n" ) d i g i t s =0 , width=20 , format= " f " ) , formatC ( srow / ( n−1) , d i g i t s =6 , width=13 , format= " f " ) , " \n" ) cat ( " Columns" , formatC ( scol , d i g i t s =6 , width=16 , format= " f " ) , formatC (m 1, − − d i g i t s =0 , width=20 , format= " f " ) , formatC ( scol / (m 1) , d i g i t s =6 , width=13 , format= " f " ) , " \n" ) 3 cat ( " I n t e r a c t i o n " , formatC ( sint , d i g i t s =6 , width=16 , format= " f " ) , formatC ( ( n−1) * (m −1) , d i g i t s =0 , width=20 , format= " f " ) , formatC ( s i n t / ( ( n−1) * (m 1) ) , d i g i t s =6 , − width=13 , format= " f " ) , " \n" ) cat ( "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−\n" ) cat ( " Total " , formatC ( stot , d i g i t s =6 , width=16 , format= " f " ) , formatC ( n *m 1, − d i g i t s =0 , width=20 , format= " f " ) , formatC ( s t o t / ( n *m 1) , d i g i t s =6 , width=13 , − format= " f " ) , " \n" ) 15 cat ( "−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−\n" ) } > anova ( x ) −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− Source | Sum of Squares | Degrees of Freedom | Mean Square −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 5 Rows Columns Interaction Total 10 1.472128 0.496731 16.153535 18.122395 3 4 12 19 0.490709 0.124183 1.346128 0.953810 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− ...
View Full Document

## This note was uploaded on 01/14/2011 for the course STATS 102A 102A taught by Professor Jandeleeuw during the Fall '10 term at UCLA.

Ask a homework question - tutors are online