Assignment 2: Analyzing with ANOVA
Submit your answers to the following questions using the ANOVA source table below. The table depicts a two-way ANOVA in which gender has two groups (male and female), marital status has three groups (married, single never married, divorced), and the means refer to happiness scores (n = 100):
- What are the independent variables and their levels? What is the dependent variable?
- State all null hypotheses associated with independent variables and their interaction? Also suggest alternate hypotheses?
- What are the degrees of freedom for 1) gender, 2) marital status, 3) interaction between gender and marital status, and 4) error or within variance?
- Calculate the mean square for 1) gender, 2) marital status, 3) interaction between gender and marital status, and 4) error or within variance.
- Calculate the F ratio for 1) gender, 2) marital status, and 3) interaction between gender and marital status.
- Identify the critical Fs at alpha = .05 for 1) gender, 2) marital status, and 3) interaction between gender and marital status.
- If alpha is set at .05, what conclusions can you make?
Source |
Sum of Squares |
(degrees of freedom [df]) |
Mean Square |
Fobt. |
Fcrit. |
Gender |
68.15 |
? |
? |
? |
? |
Marital Status |
127.37 |
? |
? |
? |
? |
Gender * Marital Status (A x B) |
41.90 |
? |
? |
? |
? |
Error (Within) |
864.82 |
? |
? |
NA |
NA |
Total |
1102.24 |
99 |
NA |
NA |
NA |
Please Note: The table that you see in the assignment has been slightly modified from the one presented in the module notes since it is beyond the scope of this unit to have students calculate p values. Instead you are asked to calculate the F value and compare it to the critical F value to determine whether the test is significant or not.
REFERENCES:
Argosy Online (2015). Argosy University Module 4. Retrieved from: http://myclassroomonline.com
Heiman, Gary W.. Behavioral Sciences STAT, 1e. Wadsworth, 2015. VitalBook file. Retrieved from: http://digitalbookshelf.argosy.edu/books/9781285404691/outline/11
One-Way and Two-Way ANOVA in Excel
Larry A. Pace, Ph.D.
Let us learn to conduct and interpret a one-way ANOVA and a two-way ANOVA for a balanced factorial design in Excel, using the Analysis ToolPak. We will perform the calculations by use of formulas and compare the results with those from the ToolPak and from SPSS. As a bonus, the reader will have access to a worksheet template for the two-way ANOVA that automates all the calculations required for Module 6, Assignment 2.
One-way ANOVA
The analysis of variance (ANOVA) allows us to compare three or more means simultaneously, while controlling for the overall probability of making a Type I error (rejecting a true null hypothesis). Researchers developed a test to measure participants’ pain thresholds. The researchers sought to determine whether participants’ hair color had any influence on her pain tolerance. Twenty participants were divided into four equal-sized groups based on natural, and their pain tolerance was measured. The dependent variable is the pain tolerance score, and the independent variable (or factor) is the participant’s hair color. In ANOVA, the independent variable is the “grouping” variable that determines group membership for each participant. Consider the following hypothetical pain threshold data. Higher scores indicate higher pain tolerance.
Hair Color |
Light Blonde |
Dark Blonde |
Light Brown |
Dark Brown |
62 |
63 |
42 |
32 |
60 |
57 |
50 |
39 |
71 |
52 |
41 |
51 |
55 |
41 |
37 |
30 |
48 |
43 |
43 |
35 |
The null hypothesis is that the population means are equal. The alternative hypothesis is that at least one pair of means is unequal. We can symbolize these hypotheses as follows:
H0: µ1 = µ2 = µ3 = µ4
H1: µ1 ≠ µ2 ≠ µ3 ≠ µ4
Partitioning the Total Sum of Squares
Analysis of variance partitions or “analyzes” the total variation into between-groups variation (based on differences between the means of the groups) and within-groups variation (based on differences between the individual values and the mean of the group to which that value belongs). Symbolically:
SStot = SSb + SSw
The total sum of squares, SStot is found (by definition) as follows. Find the overall mean of all observations, ignoring the group membership. Let us use x “double bar” to represent the mean of all the observations, which is sometimes called the “grand mean.”
We have 4 groups with 5 observations each, so we have 20 total observations. Treating all 20 observations as a single dataset, the mean is 47.6. To find the total sum of squares, subtract the mean from every value, square this deviation score, and then add up all the squared deviations:
and thus,
Although this is instructive, it is quite laborious and is not the way we would compute the sum of squares by hand. Instead, we would use a computing form that is algebraically equivalent to our definitional form, but requires us simply to square and sum our raw score values, rather than to find individual deviation scores.
The sum of squares total can be found by summing all the squared values, and subtracting from that total the sum of the individual values squared and divided by N, the total number of observations. This formula gives us exactly the same value as the definitional formula. See the Excel screen shot below. The selected cell, C16, contains the formula for squaring the sum of the x values and dividing the square by N. When we subtract that value from the sum of the squares of all the scores, the remainder is the total sum of squares.
Once you understand what the total sum of squares represents, you can easily use technology to find it without having to do repetitive calculations. Use the DEVSQ function in Excel to find the sum of squares from raw data. See the formula in the Formula Bar and the resulting value in cell E7. To get this answer, simply click in cell E7 and type the formula exactly as you see it in the Formula Bar.
Now that we have the total sum of squares, let us partition it into two different sources. The between-groups sum of squares is based only on the differences between the group means and the overall mean. We weight the group mean by the number of observations in the group (because that is the number of observations that went into calculating the mean) and multiply the squared deviation from the overall mean for that group by the group size. Add this up across all groups, and you have the between-groups sum of squares. It is easier to show this by use of a formula than to write it in words. Let us call the number of groups k. In our case, k = 4. Further, let us say there are n1 + n1+…+nk = N total observations. In our case, we have 5 + 5 + 5 + 5 = 20 observations. The definitional formula of the between-groups sum of squares is:
For our pain threshold data, we would have the following results.
The within-groups sum of squares is found by summing the squared deviations from the mean for each score in that group, and then summing across groups. The double summation just says find the squared deviations for each group and then add them all up across the groups.
The table below shows the calculation of the within-groups sum of squares.
Because of the additivity principle of variance, we could just as easily have found the within-groups sum of squares by simple subtraction:
SStot = SSb + SSw
SStot – SSb = SSw
2384.8 – 1382.8 = 1002
Partitioning the Degrees of Freedom
You will recall the concept of degrees of freedom (number of values free to vary) from your module on t tests. In ANOVA, we partition the total degrees of freedom in a fashion similar to the way we partition the total sum of squares. Remember the basic “n minus one” definition for degrees of freedom. If you have 20 total observations, you have 19 total degrees of freedom. If you have 4 groups, you have 3 degrees of freedom between groups. If you have 5 observations in a group, you have 4 degrees of freedom in that group. Using the same symbols we have already discussed, we have N – 1 total degrees of freedom. We have k – 1 degrees of freedom between groups, and we have N – k degrees of freedom within groups. The table below shows the partition of the total sum of squares and of the degrees of freedom.
Mean Squares and the F Ratio
Dividing a sum of squares by its degrees of freedom produces a “mean square” or MS. A mean square is a variance estimate, and we calculate an F ratio by dividing two variance estimates. The MSb is the variance due to differences between the means of the groups, and the MSw is the variance due to differences within the groups. By calculating an F ratio, we determine how large the between-group variance is, relative to the within-group variance. Let us build this additional information into our ANOVA summary table.
If the two variance estimates were equal, the F ratio would be 1. As the F ratio increases, the amount of variation due to “real differences” between the groups increases. As with a t test, we can find the probability of obtaining an F ratio as large as or larger than the one we obtained if the null hypothesis of no differences is true. We will compare the p value we obtain to the alpha level for our test, which we usually set to .05. If our p value is lower than .05, we reject the null hypothesis. If the p value is greater than .05, we retain the null hypothesis.
Using our current example, let us complete our ANOVA summary table.
To test the significance of an F ratio of 7.36 with 3 and 16 degrees of freedom, we can use Excel’s FDIST function. The function takes three arguments, which are the value of F, the degrees of freedom for the numerator term, and the degrees of freedom for the denominator term. We see that our F ratio has a p value much lower than .05, so our decision is to reject the null hypothesis.
Writing the Results of the ANOVA in APA Format
In our APA summary statement, we do not say we rejected the null hypothesis, but instead that the results are statistically significant, which is another way of saying the same thing. An APA-style conclusion for our analysis might be as follows:
A one-way ANOVA revealed that there are significant differences in pain thresholds among women of different hair color, F(3, 16) = 7.36, p = .003.
Using the Analysis ToolPak for a One-Way ANOVA
First, ensure you have the Analysis ToolPak installed. If you do, there will be a Data Analysis option in the Analysis group of the Data ribbon.
If you do not see this option, click on the Office Button, then Excel Options > Add-ins > Manage Excel Add-ins > Go. In the resulting dialog box, check the box in front of “Analysis ToolPak,” and click OK.
To conduct the one-way ANOVA, first make sure your data are in a worksheet arranged as follows. The labels and borders are purely optional. Because we will use labels, we must inform Excel of that fact.
Click on Data > Analysis > Data Analysis. In the Data Analysis dialog box, scroll to Anova: Single Factor, and then click OK.
Enter the input range by dragging through the entire dataset, including the labels. Check “Labels in First Row,” and then click OK. The results of the ANOVA will appear in a new worksheet.
I have formatted the table’s number formatting to be consistent with APA style.
Note the Analysis ToolPak produces the same values as we did with our manual calculations. An ANOVA summary table from SPSS is shown below. SPSS produces the same results as the Analysis ToolPak. Note SPSS uses the label “Sig.” for significance as a label for the p value.
Going Further: Effect Size
Because our ANOVA is significant, we might ask the very reasonable question, “How big is the effect?” One very good way to answer this question is to calculate an effect size index known as η2 (“eta squared”). This index tells us what proportion of the total variation in the dependent variable can be explained (or “accounted for”) by knowing the independent variable. In our case, we would ask what proportion of variation in pain tolerance can be explained by knowing a woman’s hair color. We calculate η2 by dividing the between-groups sum of squares by the total sum of squares. In our example, 1382.8 / 2384.8 = .58, so a substantial amount of the variation is explained.
Going Further: Post Hoc Comparisons
After a significant ANOVA, we know that at least one pair of means is different, but we do not yet know which pair or pairs are significantly different. We want to control the probability of making a Type I error, so we want to use a post hoc comparison procedure that holds the overall or “experimentwise” error rate to no more than our original alpha level. Two very popular post hoc procedures are the Tukey HSD (for honestly significant difference) procedure and Bonferroni-corrected comparisons. The Tukey HSD test uses a distribution called the “studentized range statistic,” while the Bonferroni procedure uses the t distribution with which you are already familiar. For that reason, we will illustrate the Bonferroni procedure. We will calculate a new value of t using the following formula:
We find the difference between two of the means, and divide that by a standard error term based on all the groups rather than just the two groups in consideration. We weight the error term by the sizes of the two groups, but for the t test, we use the within-groups degrees of freedom instead of n1 + n2 – 2 as we would in an independent-samples t test. Then, to make the Bonferroni correction, we divide the alpha level for the overall ANOVA by the number of possible pairings of means. Because we have 4 groups, there are 6 possible pairings:
Thus we would have α / 6 = .05 / 6 = .0083 as the required level of significance to reject the null hypothesis that the two means in question are different. If we wanted to do this in reverse using the p value approach, we could find the p value for our t test with dfw, and then multiply that p value by the number of possible pairings. Let us work out one example. We will compare the means of light blondes and dark brunettes:
Using Excel’s TDIST function, we find this value of t has a two-tailed p value of .0005 with 16 degrees of freedom.
This is lower than .0083, and we can reject the null hypothesis and conclude that light blondes have a significantly higher pain tolerance threshold than dark brunettes. If we use the p value approach, we can multiply .0005 by 6 to find the actual p value to be approximately .003. Rather than doing all these corrected t tests by hand, we might use a technology such as SPSS to perform all the pairwise comparisons. Note in the SPSS output that the mean difference, the standard error term, and the p value for the comparison of light blondes and dark brunettes all agree with our calculations above.