BioStatistics — 09. Theme 5 (continuation). Multifactorial Analysis of Variance
The simplest case of multifactor analysis of variance is two-factor analysis. The calculations presented here will help understand how two-factor analysis differs from two one-factor analyses and master the complex concept of factor interaction in analysis of variance
←
D.A. Shabanov, M.A. Kravchenko. Statistical Analysis of Data in Zoology and Ecology
→
Topic 5. A Brief Introduction to Analysis of Variance
Topic 5 (continued). Multifactorial Analysis of Variance
Topic 6. Comparison of Distributions
Biostatistics-08
Biostatistics-09
Biostatistics-10
5.6. Two one-way analyses of variance: "manual" calculation As with the one-way analysis, we will process a simple example containing data with specially selected numbers. These are the results of testing male and female students on three tests: "easy," "medium," and "difficult." The data are not arranged randomly but are grouped by sex, test difficulty, and within these groups, by increasing score obtained.
Sex
Test
Balls
Sex
Test
Balls
Sex
Test
Balls
Female
Light
64
Female
Hard
10
Male
Medium
43
Female
Light
69
Female
Hard
25
Male
Medium
45
Female
Light
73
Female
Hard
34
Male
Medium
65
Female
Light
90
Female
Hard
41
Male
Medium
71
Female
Light
94
Female
Hard
60
Male
Medium
96
Female
Medium
30
Male
Light
41
Male
Hard
34
Female
Medium
39
Male
Light
43
Male
Hard
41
Female
Medium
63
Male
Light
53
Male
Hard
60
Female
Medium
72
Male
Light
65
Male
Hard
64
Female
Medium
76
Male
Light
78
Male
Hard
71
{"translated_text": "[IMG_1]\n\n\n\n←\n\n\n\nD.A. Shabanov, M.A. Kravchenko. Statistical Analysis of Data in Zoology and Ecology\n\n\n\n→\n\n\n\n\n\nTopic 5. A Brief Introduction to Analysis of Variance\n\n\n\nTopic 5 (continued). Multifactor Analysis of Variance\n\n\n\nTopic 6. Comparison of Distributions\n\n\n\n\n\nBiostatistics-08\n\n\n\nBiostatistics-09\n\n\n\nBiostatistics-10\n\n\n\n5.6. Two One-Way Analyses of Variance: Manual Calculation\nAs in the case of one-way analysis, we will process a simple example containing data with specially selected numbers. These are the results of testing male and female students on three tests: \"easy,\" \"medium,\" and \"hard.\" The data are not arranged randomly but are grouped by sex, test difficulty, and within these groups—by increasing score.\n\n\n\nSex\n\n\nTest\n\n\nBalls\n\n\n\n\n\nSex\n\n\nTest\n\n\nBalls\n\n\n\n\n\nSex\n\n\nTest\n\n\nBalls\n\n\n\n\n\nFemale\n\n\nLight\n\n\n64\n\n\nFemale\n\n\nHard\n\n\n10\n\n\nMale\n\n\nMedium\n\n\n43\n\n\n\n\n\nFemale\n\n\nLight\n\n\n69\n\n\nFemale\n\n\nHard\n\n\n25\n\n\nMale\n\n\nMedium\n\n\n45\n\n\n\n\n\nFemale\n\n\nLight\n\n\n73\n\n\nFemale\n\n\nHard\n\n\n34\n\n\nMale\n\n\nMedium\n\n\n65\n\n\n\n\n\nFemale\n\n\nLight\n\n\n90\n\n\nFemale\n\n\nHard\n\n\n41\n\n\nMale\n\n\nMedium\n\n\n71\n\n\n\n\n\nFemale\n\n\nLight\n\n\n94\n\n\nFemale\n\n\nHard\n\n\n60\n\n\nMale\n\n\nMedium\n\n\n96\n\n\n\n\n\nFemale\n\n\nMedium\n\n\n30\n\n\nMale\n\n\nLight\n\n\n41\n\n\nMale\n\n\nHard\n\n\n34\n\n\n\n\n\nFemale\n\n\nMedium\n\n\n39\n\n\nMale\n\n\nLight\n\n\n43\n\n\nMale\n\n\nHard\n\n\n41\n\n\n\n\n\nFemale\n\n\nMedium\n\n\n63\n\n\nMale\n\n\nLight\n\n\n53\n\n\nMale\n\n\nHard\n\n\n60\n\n\n\n\n\nFemale\n\n\nMedium\n\n\n72\n\n\nMale\n\n\nLight\n\n\n65\n\n\nMale\n\n\nHard\n\n\n64\n\n\n\n\n\nFemale\n\n\nMedium\n\n\n76\n\n\nMale\n\n\nLight\n\n\n78\n\n\nMale\n\n\nHard\n\n\n71\n\n\n\nThus, each group contains 5 results, with a total of 6 groups in the file. Actually, based on the data provided, two one-way analyses can be performed: on the effect of subjects' sex and on the effect of test difficulty.\nThis means that we can calculate sums of squares and mean squares both for all results overall and for the two ways of subdivision: into two groups by sex and into three groups by difficulty.\nThe First One-Way Analysis\nLet us calculate the total sum of squares. [IMG_2] = 57, SS = (64–57)2 + (69–57)2 + … = 12742.\nTo calculate this value without using ANOVA, but using the Statistica package rather than a calculator or abacus, the following can be done. In the file containing the data under discussion, create (Vars / Add) another column, for example, located after the Balls column. Double-clicking on the header (the top cell with the name) of this column or selecting the Vars / Specs mode brings up the window for managing the properties of this column. In the Long name (label or formula) box at the bottom, enter (without quotes) \"=(Balls-57)**2\". Instead of the column name \"Balls,\" one could simply specify the column number, for example, \"v3\" (\"v\" is the abbreviation for variables adopted in this case, and \"3\" is the number of this column in the file). The symbol \"**\" means raising to a power; instead of it, one can also use the symbol ^ (6 + Shift in the English keyboard layout). When exiting the column header editing mode, the program will ask whether to recalculate its data and will fill it with the values of squared deviations from the mean. For subsequent recalculations of the column, one can use the command Vars/Recalculate Spreadsheet Formulas (or simply Shift+F9).\n[IMG_3]\nFig. 5.6.1. The method described in the text for simplifying calculations\nIt remains only to determine the sum of the values of the calculated squared deviations. This can be done using the descriptive statistics calculation mode: Statistics / Basic Statistics and Tables / Descriptive Statistics; in the Advanced tab, put a checkmark next to the Sum parameter and perform the calculations. There is a simpler way: select the column with the mouse, right-click on the selected area, and then select Statistics of Block Data / Block Columns / Sum. Another row will appear in the file, into which the corresponding value will be automatically inserted.\n[IMG_4]\nFig. 5.6.2. A quick calculation method using the Statistics of Block Data menu, which is invoked by right-clicking\nIn a similar manner, we will determine the mean sums of squares for females and males (with the corresponding values of group means being inserted into the file column for calculating the squared differences of means, and then summing them in the blocks covering the required groups).\n[IMG_5]F = 56, SSF = (64–56)2 + (69–56)2 + … = 8594; [IMG_6]M = 58, SSM = (41–58)2 + (43–58)2 + … = 4118.\nBy summing the obtained values, we will get SSerror(S) (the \"S\" symbol means that we are talking about the error when dividing the population by the \"Sex\" attribute).\nSSerror(S) = SSF + SSM = 8594 + 4118 = 12712. The degrees of freedom for this value is dferror(S) = 30 — 2 = 28 (thirty estimates and two equations that link their two groups).\nMSerror(S) = SSerror(S) / dferror(S) = 12712/28 = 454.\nWe calculate MSeffect(S). SSeffect(S) = nF × ([IMG_7]F – [IMG_8])2 + nM × ([IMG_9]M – [IMG_10])2 = 15 × 1 + 15 × 1 = 30.\ndfeffect(S) = 1. MSeffect(S) = 30.\nWe have obtained the mean squares for the effect of sex and its error. If in comparison by Student's and Fisher's tests, when calculating Fisher's test the larger variance is divided by the smaller one, in this case we must act differently. To check the statistical significance of the division of the entire population by the attribute of interest to us, we must divide the mean square of the effect by the mean square of the error. The result is telling:\nF = MSeffect(S) / MSerror(S) = 30/454 = 0.061.\nOne need not check the statistical significance of such a result from tables. ANOVA states that the probability of a difference of means not exceeding the recorded one, with random division of their population into parts (i.e., the p-value), equals 0.799. Thus, in the one-way analysis we recorded that the dependence of the entire set of scores on the subjects' sex is insignificant. However (looking ahead), the two-way analysis can substantially correct this statement.\nThe Second One-Way Analysis\nThe one-way analysis related to the effect of test difficulty will be performed using the ANOVA procedure in the Statistica package, since we have already figured out the \"manual\" calculations. Here are its results (ignore the Intercept row!).\n[IMG_11]\nFig. 5.6.3. Result of determining the effect of test difficulty on testing results\nAs can be seen, test difficulty significantly affects their results. Since the 30 available scores were divided into three groups, the degrees of freedom for the error is 27.\nThus, the two one-way analyses showed that the effect of one factor is statistically insignificant, while that of the second factor is statistically significant. This result is clearly visible on the corresponding graphs.\n[IMG_12]\nFig. 5.6.4. Graphical representation of the results of the two one-way analyses (separately)\nInterestingly, comparison of test results using Student's and Fisher's tests for the Light — Medium and Medium — Hard pairs shows an insignificant difference, and only for the Light — Hard pair is the result statistically significant.\nBut in both analyses we used not all the available data. We divided the data into two and into three groups, whereas there are 6 in our file! The two-way analysis can reveal new circumstances.\n\n\n5.7. Two-Way Analysis of Variance: Manual Calculation\nIn one-way analyses, we used two models to explain the variability of test scores.\nThe model related to the effect of sex can be represented as: [IMG_13], where xis is the i-th value of the studied quantity at the s-th value of the studied factor Sex; [IMG_14] is the overall mean; Ss is the effect of the s-th value of the Sex factor; [IMG_15] is the \"error,\" the contribution of the individuality of the object when grouping by the values of the specified factor.\nSimilarly, the second model could be represented as: [IMG_16].\nHow can we combine these models? The \"error\" value in the first equation ([IMG_17]) includes both individuality and the effect of test difficulty; similarly, the \"error\" [IMG_18] includes the effect of subjects' sex. By considering the mean value of the results obtained by representatives of each sex, we can isolate the part of the error related to test difficulty; when analyzing the response to tests of different difficulty, one can isolate the contribution of sex to the change in result.\nIn general, one can write [IMG_19], where xist is the i-th value of the studied quantity at the s-th value of the studied factor Sex and the t-th value of the studied factor Test, and STst is the result of the interaction of the Sex and Test factors at their s-th and t-th values. Thus, we can use the following decomposition of the sum of squares into components: SS = SSS + SST + SSST + SSerror. By performing one-way analyses, we have already established that SS = 12712, SSS = 30, and SST = 2780. The sums of squares of errors that we calculated before differ from the one that should be obtained for the two-way analysis, since now it must be calculated for 6 groups. Without discussing the process of its calculation, which has become trivial given the understanding of the preceding reasoning, we note that SSerror = 7592. But how to calculate SSST?\n[IMG_20]. In this formula, the symbol \"s\" denotes the gradations of factor S — Sex (taking 2 values), and \"t\" — the three gradations of factor T — Test. For the case under consideration, we can write:\nSSST = nFemaleLight × ([IMG_21]FemaleLight – [IMG_22]Female – [IMG_23]Light + [IMG_24])2 + nFemaleMedium × ([IMG_25]FemaleMedium – [IMG_26]Female – [IMG_27]Medium + [IMG_28])2 + nFemaleHard × ([IMG_29]FemaleHard – [IMG_30]Female – [IMG_31]Hard + [IMG_32])2 + nMaleLight × ([IMG_33]MaleLight – [IMG_34]Male – [IMG_35]Light + [IMG_36])2 + nMaleMedium × ([IMG_37]MaleMedium – [IMG_38]Male – [IMG_39]Medium + [IMG_40])2 + nMaleHard × ([IMG_41]MaleHard – [IMG_42]Male – [IMG_43]Hard + [IMG_44])2\nLet us provide the list of group means. [IMG_45]FemaleLight = 78; [IMG_46]FemaleMedium = 56; [IMG_47]FemaleHard = 34; [IMG_48]MaleLight = 56; [IMG_49]MaleMedium = 64; [IMG_50]MaleHard = 54. Additionally, [IMG_51]Female = 56; [IMG_52]Male = 58, as well as [IMG_53]Light = 67; [IMG_54]Medium = 60; [IMG_55]Hard = 44. Finally, [IMG_56] = 57. For all groups n = 5.\nSSST = 5×(78–56–67+57)2 + 5×(56–56–60+57)2 + 5×(34–56–44+57)2 + 5×(56–58–67+57)2 + 5×(64–58–60+57)2 + 5×(54–58–44+57)2 = 5×[122 + 32 + 92 + 122 + 32 + 92] = 2340.\nInterpreting the results obtained will be easier with ANOVA in the Statistica package, but now we will understand where the SS, MS, and F values given in the analysis results came from.\n\n\n5.8. Two-Way Analysis Using ANOVA in Statistica Package\nHaving opened the described file in the Statistica package, we select the type of analysis Statistics / ANOVA. In the Quick dialog, in the Type of analysis window, we specify Factorial ANOVA, and in the Specification method window, we specify Quick specs dialog.\n[IMG_57]\nFig. 5.8.1. Starting window for conducting multifactor analysis\nClicking OK takes us to the following dialog. In the Quick tab, it is necessary to specify the columns with factors and the variables under study, as well as the necessary factor codes. Clicking the Variables button, in the Dependent variables list we specify the Balls column, and in the Categorical predictors (factor) window — the Sex and Test columns (in this and similar windows, if several variables need to be selected, they can be highlighted by clicking on their names while holding the Control key). We press OK. In the Factor codes dialog for both factors, we select All.\n[IMG_58]\nFig. 5.8.2. Selection of factor codes (values of the Sex and Test variables for which the analysis will be performed). In both cases, the All buttons are pressed\nThe next OK takes us to the ANOVA Results 1 window. The All effects button outputs the analysis of variance table.\n[IMG_59]\nFig. 5.8.3. Main table of two-way analysis results\nAs can be seen from the table, the effect of the Sex attribute is not significant, but both the effect of the Test attribute and the Sex*Test interaction turn out to be statistically significant. To understand what this interaction consists of, it is useful to construct a graph using the All effects / Graphs button in the ANOVA Results 1 window. In the dialog that opens, we select the Sex*Test row. The program offers two options for constructing the graph: with the Test attribute or the Sex attribute displayed on the abscissa axis. We will present both options.\n[IMG_60]\n\nFig. 5.8.4. Variant of the graph reflecting the interaction of factors, where the Test attribute is shown on the abscissa axis, and the points corresponding to specific values of the Sex attribute are shown as lines\n\n\n[IMG_61]\nFig. 5.8.5. Variant of the graph reflecting the interaction of factors, where the Sex attribute is shown on the abscissa axis, and the points corresponding to specific values of the Test attribute are shown as lines\n\n\nObviously, it is easier to work with the first graph. The lines on it show the results of subjects of both sexes. We see that as tests become more difficult, women receive lower scores. The reaction of men to increasing difficulty is quite different: they solve easy tests not very well (perhaps simply from boredom), improve their results on tests of medium difficulty, and solve hard tests only slightly worse than easy ones (perhaps they perceive them as an intellectual challenge and therefore really exert themselves).\nThus, the conclusion that sex does not affect test results needs correction. There is no basis to claim that one sex handles tests worse or better than the other; however, it is clear that men react to increasing test difficulty quite differently than women. Thus, sex does affect scores, but not by raising or lowering the grade, but by changing the response to changes in another factor.\nIn the possibility of studying effects of this kind—factor interactions—lies one of the main advantages of analysis of variance."}
Fig. 5.8.2. Selection of factor codes (values of variables Sex and Test for which the analysis will be performed). In both cases, the All buttons are pressed.
The next OK takes you to the ANOVA Results 1 window. The All effects button displays the analysis of variance table.
Fig. 5.8.3. Main table of two-factor analysis results
As can be seen from the table, the effect of the Stat variable is statistically insignificant, but the effect of the Test variable and the Stat*Test interaction are statistically significant. To understand what this interaction consists of, it is useful to build a graph using the All effects / Graphs button in the ANOVA Results 1 window. In the dialog that opens, select the Stat*Test row. The program offers two options for building the graph: displaying the Test variable on the x-axis or the Stat variable. We will present both options.
Fig. 5.8.4. A variant of the graph showing the interaction of factors, where the Test variable is shown on the x-axis, and points corresponding to certain values of the Stat variable are depicted by lines
Fig. 5.8.5. A variant of the graph showing the interaction of factors, where the Stat variable is shown on the x-axis, and points corresponding to certain values of the Test variable are depicted by lines
It is obvious that the first graph is easier to work with. The lines on it show the results of participants of both sexes. We see that women get lower scores with increasing test difficulty. Men's reaction to difficulty is completely different: they perform poorly on easy tests (perhaps due to boredom), improve their results on medium difficulty tests, and only three solve difficult tests worse than easy ones (probably perceiving them as an intellectual challenge and therefore straining seriously). Thus, the conclusion that sex does not affect test results needs correction. There is no reason to claim that one sex performs better or worse on tests than the other; however, it is clear that men react to test difficulty completely differently than women. This means that sex does affect scores, but not by increasing or decreasing the score, but by changing the reaction to a change in the other factor. One of the main advantages of analysis of variance is manifested in the research possibilities of such interaction effects.