Chapter 19: The Two-Factor ANOVA for Independent Groups An extension of the One-Factor ANOVA experiment has more than one independent variable, or ‘factor’. For example, suppose we were interested in how both caffeine and beer influence response times. You could run two separate studies, one comparing caffeine to a control group, and another comparing beer to another control group. However, a more interesting experiment would be a ‘two-factor’ design and put subjects into one of four categories, which includes beer only, caffeine only and beer and caffeine. Note that for two-factor ANOVAS, the sample size in each group is always the same. Note: we’ll be skipping sections 19.8, 19.9, and from the book
Chapter 19: The Two-Factor ANOVA for Independent Groups Here’s are some summary statistics for an example data set for n=12 subjects in each group (or cell) SS W is the sums of squared deviations from the means within each cell, just like for the 1-Factor ANOVA No BeerBeer No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Grand mean: 1.02 SS total = 3.07
No BeerBeer Response Time (sec) No Caffeine Caffeine It is common to plot the results of Two-Way experiments like this, with error bars representing the standard error of the mean. No BeerBeer No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Grand mean: 1.02 SS total = 3.07
No BeerBeer Response Time (sec) No Caffeine Caffeine What statistical tests can we conduct on these results? 1)Effect of Beer on response times, averaged across Caffeine levels – a ‘main effect’ for Beer 2)Effect of Caffeine on response times, averaged across Beer levels – a ‘main effect for Caffeine 3)Interaction between Caffeine and Beer. A significant interaction means that the main effects do not collectively explain all of the influence of the factors on the dependent variable. Graphically, interactions happen when the lines are not parallel.
No BeerBeer Response Time (sec) No Caffeine Caffeine The main effect for rows the difference between the means for the rows, averaging across the columns. No BeerBeer No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Main effect for ROWS In this example, it is used to test for the effect of Caffeine on response times, averaging across the No Beer and Beer groups. Statistically, its significance is determined by a One-Factor ANOVA, ‘collapsing’ across the columns Graphically, it is a test if to see if the middle of the blue line is different than the middle of the green line.
No BeerBeer Response Time (sec) No Caffeine Caffeine The main effect for columns the difference between the means for the columns, averaging across the rows. No BeerBeer No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Main effect for COLUMNS In this example, it is used to test for the effect of Beer on response times, averaging across the No Caffeine and Caffeine groups. Graphically, it is a test if to see if the midpoint between the blue and green lines differs across the groups (or columns). Statistically, its significance is determined by a One-Factor ANOVA, ‘collapsing’ across the rows
No BeerBeerRow means No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 Mean: 1.12 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Mean: 0.91 Column meansMean: 0.94Mean: 1.09Grand mean: 1.02 SS total = 3.07 No BeerBeer Response Time (sec) No Caffeine Caffeine Main effects for rows and columns are calculated by averaging the data across rows and columns.
We can partition the total variance into these components: SS total SS within cell SS between SS rows SS cols SS rows x cols With degrees of freedom: df total =n total -1 df within cell =n total -RxC SS between df rows =R-1df cols =C-1 df rows x cols =(R-1)(C-1) C (R) is the total number of scores for that column (row)
We can partition the total variance into these components: Three F-tests can then be conducted by computing the following four variances: s 2 wc estimates the variance within each cell, or ‘inherent variance’. This is also an estimate of the population variance 2. s 2 wc is used as the denominator for all of the F-tests – just like the 1-way ANOVA s 2 R estimates the inherent variance plus the main effect for the row factor. It increases with variance across the row means. s 2 C estimates the inherent variance plus the main effect for the column factor. It increases with variance across the column means. s 2 RxC estimates the inherent variance plus the interaction effect. If s 2 RxC is small (near s 2 wc ) then the total variance is completely explained by the inherent variance plus the effects of the row and column factors alone. Hence, no interaction between the two factors.
The four variances are used to compute the three F-ratios to make the three hypothesis tests about the row factor, column factor and the interaction: tests for the main effect of the row factor and has dfs of (R-1) and (n total – RxC) tests for the main effect of the column factor and has dfs of (C-1) and (n total – RxC) tests for the interaction between the row and column factors and has dfs of (R-1)x(C-1) and (n total – RxC) SourceSSdfs2s2 F RowsSS R R-1SS R /df R s 2 R /s 2 wc ColumnsSS C C-1SS C /df C s 2 C /s 2 wc RxCSS RxC (R-1)x(C-1)SS RxC /df RxC s 2 RxC /s 2 wc Within cellsSS wc n total -RxCSS wc /df wc TotalSS total n total -1 Typically, we conduct a two-factor ANOVA by filling in a table like this:
No BeerBeerRow means No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 Mean: 1.12 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Mean: 0.91 Column meansMean: 0.94Mean: 1.09Grand mean: 1.02 SS total = 3.07 SourceSSdfs2s2 F RowsSS R 1SS R /df R s 2 R /s 2 wc ColumnsSS C 1SS C /df C s 2 C /s 2 wc RxCSS RxC 1SS RxC /df RxC s 2 RxC /s 2 wc Within cellsSS wc 44SS wc /df wc Total We can start filling in the table from our example about beer and caffeine.
No BeerBeerRow means No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 Mean: 1.12 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Mean: 0.91 Column meansMean: 0.94Mean: 1.09Grand mean: 1.02 SS total = 3.07 SS within = SourceSSdfs2s2 F RowsSS R 1SS R /df R s 2 R /s 2 wc ColumnsSS C 1SS C /df C s 2 C /s 2 wc RxCSS RxC 1SS RxC /df RxC s 2 RxC /s 2 wc Within cells Total SourceSSdfs2s2 F RowsSS R 1SS R /df R s 2 R /s 2 wc ColumnsSS C 1SS C /df C s 2 C /s 2 wc RxCSS RxC 1SS RxC /df RxC s 2 RxC /s 2 wc Within cellsSS wc 44SS wc /df wc Total3.0747
No BeerBeerRow means No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 Mean: 1.12 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Mean: 0.91 Column meansMean: 0.94Mean: 1.09Grand mean: 1.02 SS total = 3.07 SourceSSdfs2s2 F Rows ColumnsSS C 1SS C /df C s 2 C /s 2 wc RxCSS RxC 1SS RxC /df RxC s 2 RxC /s 2 wc Within cells Total SS rows =
No BeerBeerRow means No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 Mean: 1.12 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Mean: 0.91 Column meansMean: 0.94Mean: 1.09Grand mean: 1.02 SS total = 3.07 SS cols = SourceSSdfs2s2 F Rows Columns RxCSS RxC 1SS RxC /df RxC s 2 RxC /s 2 wc Within cells Total3.0747
No BeerBeerRow means No CaffeineMean: 1.08 SS W = 0.66 Mean: 1.16 SS W = 0.54 Mean: 1.12 CaffeineMean: 0.80 SS W = 0.67 Mean: 1.02 SS W = 0.32 Mean: 0.91 Column meansMean: 0.94Mean: 1.09Grand mean: 1.02 SS total = 3.07 SS rows x cols = SourceSSdfs2s2 F Rows Columns RxC Within cells Total3.0747
SourceSSdfs2s2 FF crit Rows Columns RxC Within cells Total We can either use our F-tables (Table E) to find the critical values of F SourceSSdfs2s2 FP-value Rows Columns RxC Within cells Total Or, more commonly, we can use our F-calculator to calculate the corresponding p-value for our observed values of F.
SourceSSdfs2s2 FP-value Rows Columns RxC Within cells Total No BeerBeer Response Time (sec) No Caffeine Caffeine We show a significant main effect for rows (Caffeine) and for Columns (Beer), but not a significant interaction between rows and columns (Caffeine x Beer).
Columns Score Row 1 Row 2 SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Let’s play “guess that significance!”
Row 1 Row Columns Score SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Guess that significance!
Row 1 Row 2 SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Columns Score Guess that significance!
Row 1 Row Columns Score SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Guess that significance!
Row 1 Row Columns Score SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Guess that significance!
Row 1 Row 2 SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Columns Score Guess that significance!
Row 1 Row Columns Score SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Guess that significance!
Row 1 Row 2 SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Guess that significance!
Row 1 Row 2 SourceSSdf s 2 Fp-value Rows Columns RxC Within Total Guess that significance! Columns Score
n = 12Exercise NoneA littleA lot Diet AMean: SS W = Mean: SS W = Mean: SS W = Diet BMean: SS W = Mean: SS W = Mean: SS W = Grand mean: SS total = Suppose you wanted to test the effects of diet and exercise on body mass index. You choose two diets (A and B) and three levels of exercise (none, a little, a lot). You then find 12 subjects for each group and obtain the following descriptive statistics: Conduct a two factor ANOVA to determine if there is a main effect for diet, exercise and if there is an interaction between diet and exercise.
noneA littleA lot Exercise BMI Diet A Diet B First, let’s plot the data with error bars as the standard error of the means.
n = 12Exercise NoneA littleA lot Diet AMean: SS W = Mean: SS W = Mean: SS W = Mean: Diet BMean: SS W = Mean: SS W = Mean: SS W = Mean: Mean: 20.78Mean: 20.35Mean: Grand mean: SS total = SourceSSdfs2s2 Fp-value Rows SS R R-1SS R /df R s 2 R /s 2 wc Columns SS C C-1SS C /df C s 2 C /s 2 wc RxC SS RxC (R-1)x(C-1)SS RxC /df RxC s 2 RxC /s 2 wc Within cells SS wc n total -RxCSS wc /df wc Total SS total n total -1
n = 12Exercise NoneA littleA lot Diet AMean: SS W = Mean: SS W = Mean: SS W = Mean: Diet BMean: SS W = Mean: SS W = Mean: SS W = Mean: Mean: 20.78Mean: 20.35Mean: Grand mean: SS total = SourceSSdfs2s2 Fp-value Rows Columns RxC Within cells Total
No main effect for Rows (Diet) Main effect for Columns (Exercise) No interaction between rows and columns (Diet and Exercise) SourceSSdfs2s2 Fp-value Rows Columns RxC Within cells Total noneA littleA lot Exercise BMI Diet A Diet B