Documente Academic
Documente Profesional
Documente Cultură
We can extend the idea of a one-way ANOVA, which tests the effects of one factor on a response variable, to a two-way ANOVA which tests the effects of two factors and their interaction on a response variable. Thus, each experimental unit is classified by two factors; e.g., treatment group and sex, forest location and soil groups, type of thinning and site quality class, etc. Each factor can have different levels; e.g., two levels for sex: male and female, four levels of thinning prescriptions: low, medium, high, control. The two-way ANOVA tests the null hypotheses of equal means for each factor, as we will see in the upcoming example.
Sources of Variation: As with the t-test and the one-way ANOVA, we assume that the variances are homogeneous. In a manner analogous to the one-way ANOVAs within-group sums of squares, we can calculate a within-cells sums of squares and corresponding degrees of freedom,
which under the assumption of constant variance, can be used to obtain a pooled variance common to all cells:
2 n within-cells SS = (X ijl X ij ) i =1 j=1 l =1 a b
within-cells DF = ab(n 1), where: a = number of levels in factor A b = number of levels in factor B n = number of replicates. The pooled variance (s 2 ) , which is the best estimate of 2, is found by: p
within cells SS error SS = = MSE . within cells DF error DF We also need an estimate of the variability among the cells. This is analogous to groups in the one-way ANOVA:
cells SS = n (X ij X ) ,
a b 2 i =1 j=1
cells DF = ab 1. Finally, we need to know the variability among all the data, N, which is also analogous to that of the one-way ANOVA: total SS =
(X
a b n i =1 j=1 l =1
ijl
X) ,
2
total DF = N 1. In a two-way ANOVA, we typically want to know about the differences between the two factors when considered independently. Thus, we want to examine the specific components of the cells
SS and cells DF. We can examine these differences by only considering one factor at a time in the ANOVA. So, for factor A: SS(A) = bn (X i. X ) ,
a 2 i =1
DF(B) = b 1. However, the sums of squares and degrees of freedom for factor A and factor B will not exactly sum to the cells SS because of interaction between the factors. The relationship is additive and it can be expressed as: SS(AxB) = SS(Cells) SS(A) SS(B), DF(A x B) = DF(Cells) DF(A) DF(B) = (a 1)(b 1). An interaction between the two factors implies that they are not independent of each other. We will test interaction to determine if it is actually significant in an upcoming example.
As with the one-way ANOVA, you can divide the different SS by their corresponding DF to obtain a variance, called a mean square: MS( A ) = SS( A ) , DF( A ) SS(B ) , DF(B )
MS(B ) =
MS( AxB) =
MS(Error ) =
SS(Error ) . DF(Error )
Error MS is usually called the mean square error (MSE). As with the one-way ANOVA, these ratios are F-distributed. So, we can calculate corresponding F-statistics and compare to a onetailed critical value from the F-distribution for our hypothesis tests (for a Model I ANOVA see discussion later in the notes):
F= MS( A ) , for Ho: no effect of factor A on response variable, MSE
MS(B ) , for Ho: no effect of factor B on response variable, MSE MS( AxB) , for Ho: no interaction between factor A and factor B. MSE
F=
F=
Cells Factor A
n (X
a b i =1 j=1
ij
X)
2
ab - 1
bn (X i. X )
a
an (X . j X )
j=1
i =1 b
F=
SS(Error ) DF(Error )
(X
a b n i =1 j=1 l =1
ijl
X)
Ho2: There is no difference in the mean plasma calcium concentration between male and
Ho3: There is no interaction of sex and hormone treatment on the mean plasma calcium
concentration of birds.
Ha3: There is an interaction of sex and hormone treatment on the mean plasma calcium
I used the example SAS program, TwoWayAnova.sas, with the data presented in Zar to perform the ANOVA. I obtained the following ANOVA table:
Source of Variation Cells Treatment Gender Treatment x Gender Error Total Sums of Squares Degrees of (SS) Freedom (DF) 1461.3255 3 1386.1125 1 70.3125 1 4.9005 1 301.3920 16 1762.2175 19 Mean Square (MS) F-statistic p-value
As you can see from the table, the F-statistic for the null hypotheses of no interaction (Ho3) is not significant (p-value = 0.6170 > 0.05). The F-statistic for the null hypothesis of no difference between sexes (Ho2) is also not significant (p = 0.0713 > 0.05). However, the F-statistic for the null hypothesis of no treatment effect (Ho1) is highly significant ( p < 0.0001 << 0.05). Thus, we conclude that hormone treatment affects the plasma calcium concentration in this sample of birds.
If we had more than two levels in the treatment effect (e.g., two treatments and one control = 3 levels), we could use multiple comparison tests to determine where differences exist between treatments. The procedure is the same as that for multiple comparisons in a one-way ANOVA. If both factors are significant and they have more than two levels, we can perform multiple comparison tests for both factors separately.
Assumptions of ANOVA
The assumptions in the two-way ANOVA are the same as in the t-tests and one-way ANOVA: homogeneity of variance and normally distributed data. You can test these assumptions using the procedures we have already discussed. Remember that ANOVA is very robust and can thus handle all but the most extreme violations of these assumptions. If you are convinced that the assumptions are violated, you can resort to some non-parametric analogs of two-way ANOVA. However, many of these non-parametric procedures are not fully developed or widely available in computer programs.
You should also know that there are three types of two-way (and n-way) ANOVAs: 6
1. Model I or Fixed-effects ANOVA: In this type of two-way ANOVA, the factor levels are fixed by the experimenter. Thus, the factors are said to be crossed, as we previously mentioned. The example we just completed is an example of a Model I ANOVA. Note: This is the same Model I ANOVA we discussed for the one-way ANOVA.
Another thing that differs from the one-way ANOVA is the interaction term. In our example, we found that the interaction effect was not significant. Thus, we could then test for individual factor effects. If the interaction had been significant, we could not say anything meaningful about factor effects because the difference between the levels of one factor is not constant at all levels of the other factor (see Zars Figure 12.2, page 260).
2. Model II or Random-effects ANOVA: This rare type of two-way ANOVA occurs when the levels of the factor are selected randomly. The F-statistics are calculated differently than the Model I ANOVA (see Zars Table 12.3, page 262). Note: This is the same Model II ANOVA we discussed for the one-way ANOVA. 3. Model III or Mixed-effects ANOVA: This type of factorial design has both a fixed and random effect factor. The F-statistics are again calculated differently than either the Model I or Model II ANOVA (see Zars Table 12.3, page 262). For example, if factor A is fixed and factor B is random, the F-statistics are calculated as: Factor A (fixed): F =
MS( A ) , MS( AxB)
MS(B ) , MSE
Factor B (random): F =
Interaction: F =
Source of Variation
F-statistic
Treatment MS Re mainder MS
b (X i. X )
a i =1
a-1
b1 (a 1)(b-1) ab 1 = N -1
a (X . j X )
b j=1
Re mainder SS Re mainder DF
(X
a b i =1 j=1
ij
X)
Example: A researcher is interested in the effect of several herbicides on the spike weight
(ounces) of gladiolus. Heres the data: TREATMENT Control Block 1 Block 2 Block 3 Block 4 1.25 1.73 1.82 1.31 A 2.05 1.56 1.68 1.69 B 1.95 2.00 1.83 1.81 C 1.75 1.93 1.70 1.59
We will test the following hypothesis: Ho: The mean spike weight is the same for each of the four herbicide treatments. Ha: not Ho. = 0.05. After running SAS with these data, we get the ANOVA table:
Source of Degrees of Mean Square Sums of Squares (SS) F-statistic Variation Freedom (DF) (MS) Blocks 0.0947 3 Treatment 0.2777 3 2.2153 0.0926 Remainder 0.3765 9 0.0418 Total 0.7489 15 >>>Note: I did not include all the output from SAS in this table, notably the block MS.
Fcritical = F0.05(1), 3, 9 = 3.86 Decision Rule: If F 3.86, then reject Ho; otherwise do not reject Ho. Conclusion: Since 2.2153 < 3.86, do not reject Ho and conclude that none of the four herbicide treatments affect gladiolus spike weight in this sample (p = 0.1561).
10
Note: You can perform multiple comparisons/contrasts for the fixed effects factor (i.e., treatments) in the same manner as the two-way ANOVA, though it was unnecessary in this case since we did not reject Ho (see Zar, page 274, Section 12.5).
Friedmans Test
This is the non-parametric analog of the randomized block ANOVA. It is useful when your data for this design do not meet the assumptions of the parametric ANOVA. Like other nonparametric techniques, the analysis is performed on ranks rather than the original data. To carry out this test: 1. Rank the treatments within each block. 2. Calculate the rank sums, Ri, for each treatment. 3. Find chi-square statistic: 2 = r
a 12 R i2 3b(a + 1) . ba (a + 1) i 1
4. Compare the chi-square statistic to a critical value from Table B.14 in appendix. If the critical value is not in the table, compare to a chi-square value with (a 1) degrees of freedom, which approximates the critical value (though it tends to be conservative more likely to commit a Type II error see Zar, page 277 to 279, for a suggested solution).
11
Example: Lets continue with the gladiolus example from before. First, rank the data within
each block and get the rank sums: TREATMENT Control Block 1 Block 2 Block 3 Block 4 Rank Sums 1 2 3 1 7 A 4 1 1 3 9 B 3 4 4 4 15 C 2 3 2 2 9
Test statistic: 2 = r
Decision Rule: If 2 7.80 (value from Table B.14), then reject Ho; otherwise do not reject Ho. r Conclusion: Since 5.4 < 7.8 (0.1 < P < 0.2), do not reject Ho same conclusion as before.
Note: I also provided an example SAS file (FriedmansTest.sas) on the webpage. Use the second test statistic, Row Mean Scores Differ, for hypothesis testing. Also, you can perform nonparametric multiple comparisons/contrasts as for the parametric randomized block ANOVA, though again it was unnecessary since we did not reject Ho (see Zar, page 280). However, SAS does not provide non-parametric multiple comparisons so you will have to calculate them by hand/programming.
12