From Socr Show
Contents
General Advance-Placement (AP) Statistics Curriculum - Two-Way Analysis of Variance (ANOVA)In the previous section, we discussed statistical inference in comparing k independent samples separated by a single (grouping) factor. Now we will discuss variance decomposition of data into (independent/orthogonal) components when we have two (grouping) factors. Hence, this procedure called Two-Way Analysis of Variance. Motivational ExampleSuppose we want to study the dynamics of the US Consumer Price Index (CPI), which is a major economic indicator that measures the average price changes of consumer goods and services. To motivate 2-way ANOVA we can focus on a 5-year annual summary of the CPI for different types of consumer good (items). The complete dataset can be found here and a small 5-year excerpt is included below. Clearly, we have two-factors that may explain the dynamics of the CPI - year and item-type.
Using the SOCR Charts (see SOCR Box-and-Whisker Plot Activity and Dot Plot Activity), we can generate plots that enable us to compare visually the 4 different CPI items (food, housing, transportation and medical-care) across the 5 years. We can also plot the time courses of these 4 CPI items (using the SOCR Line Chart. Two-Way ANOVA CalculationsLet's make the following notation: Two-way Model: yi,j,k = μ + τi + βj + γi,j + εi,j,k, for all , and . Here μ is the overall mean response, τi is the effect due to the ith level of factor A, βj is the effect due to the jth level of factor B and γi,j is the effect due to any interaction between the ith level of factor A and the jth level of factor B. yi,j,k = the A-factor level i and B-factor level j, observation-index k measurement. k = number of replicates. ai = number of A-factor observations at level i, . bj = number of B-factor observations at level j, . N = total number of observations, . The mean of the A-factor group mean at level i and B-factor at level j is: The grand mean is: .When an factorial experiment is conducted with an equal number of observation per treatment combination, and where AB represents the interaction between A and B, the total (corrected) sum of squares is partitioned as: SS(Total) = SS(A) + SS(B) + SS(AB) + SSEHypothesesThere are three sets of hypotheses with the two-way ANOVA. The null hypotheses for each of the sets
FactorsThe two independent variables in a two-way ANOVA are called factors (denoted by A and B). The idea is that there are two variables, factors, which affect the dependent variable (Y). Each factor will have two or more levels within it, and the degrees of freedom for each factor is one less than the number of levels. Treatment GroupsTreatment Groups are formed by making all possible combinations of the two factors. For example, if the first factor has 5 levels and the second factor has 6 levels, then there will be different treatment groups.Main EffectThe main effect involves the independent variables one at a time. The interaction is ignored for this part. Just the rows or just the columns are used, not mixed. This is the part which is similar to the one-way analysis of variance. Each of the variances calculated to analyze the main effects is like the between variances Interaction EffectThe interaction effect is the effect that one factor has on the other factor. The degree of freedom here is the product of the two degrees of freedom for each factor. Within VariationThe Within variation is the sum of squares within each treatment group. You have one less than the sample size (remember all treatment groups must have the same sample size for a two-way ANOVA) for each treatment group. The total number of treatment groups is the product of the number of levels for each factor. The within variance is the within variation divided by its degrees of freedom. The within group is also called the error. F-TestsThere is an F-test for each of the hypotheses, and the F-test is the mean square for each main effect and the interaction effect divided by the within variance. The numerator degrees of freedom come from each effect, and the denominator degrees of freedom is the degrees of freedom for the within variance in each case. Two-Way ANOVA TableIt is assumed that main effect A has a levels (and df(A) = a-1), main effect B has b levels (and (df(B) = b-1), r is the sample size of each treatment, and is the total sample size. Notice the overall degree of freedom is once again one less than the total sample size.
To compute the difference between the means, we will compare each group mean to the grand mean. SOCR ANOVA CalculationsSOCR Analyses provide the tools to compute the 2-way ANOVA. For example, the ANOVA for the Consumer Price Index data above may be easily computed - see the image below. Note that SOCR ANOVA requires the data to be entered in the column format of the first table in this section. Under the Graphs tab-pane, we can see a variety of plots demonstrating the ANOVA results. The ANOVA table for these data is reported under the Results tab-pane. Sample Size = 20 Dependent Variable = CPI-Value Independent Variable(s) = Year Item --- Two-Way Analysis of Variance Results --- Variable: YearDegrees of Freedom = 4 Residual Sum of Squares = 2624.8073168000 Mean Square Error = 656.2018292000 F-Value = 19.3405175758 P-Value = .0000363212 Variable: ItemDegrees of Freedom = 3 Residual Sum of Squares = 71900.0898230001 Mean Square Error = 23966.6966076667 F-Value = 706.3807145121 P-Value = .0000000000 Residual: Degrees of Freedom = 12 Residual Sum of Squares = 407.1463920000 Mean Square Error = 33.9288660000 F-Value = 322.4822657900 P-Value = 0.0 R-Square = .9945664582Two-Way ANOVA ConditionsThe Two-way ANOVA is valid if:
Clinical example: Knee Pain StudyThe following data was collected in a large knee pain study (N=6,046) by TMT Medical and UCLA investigators using an online questionnaire. The goals of the study was to identify the relations between a large number of clinical markers, patient phenotypes and imaging data of knee pain. One specific set of research questions the investigators were interested in related to the effects of mild treatment by applying hot or cold patches to the affected knee areas. The 2 tables below present identical information, however, the second table may be used to paste in the data into the SOCR 2-way ANOVA Applet or any other SOCR analysis tool. Try to answer 2 types of questions:
Problems
Translate this page:
How many degrees of freedom does a twoThe df for subjects is the number of subjects minus number of treatments. When the matched values are stacked, there are 9 subjects and three treatments, so df equals 6. When the matched values are in the same row, there arr 6 subjects treated in two ways (one for each row), so df is 4.
What is the main effect in twoWith the two-way ANOVA, there are two main effects (i.e., one for each of the independent variables or factors). Recall that we refer to the first independent variable as the J row and the second independent variable as the K column. For the J (row) main effect… the row means are averaged across the K columns.
What is twoA two-way ANOVA test is a statistical test used to determine the effect of two nominal predictor variables on a continuous outcome variable. A two-way ANOVA tests the effect of two independent variables on a dependent variable.
How many F ratios must we calculate for a twoThe two-way factorial design requires a researcher to test three null hypotheses-one that is concerning the effect of factor1, another concerning the factor2, and the third concerning the joint effect of factor 1 and factor 2. Therefore: There are 3 F-ratios involved in the two-way ANOVA.
|