# Examples ## Completely Randomized Design Single factor CRD is equivalent to One-Way ANOVA. ### Example 1 - CRD ```py import doex exp = doex.CompletelyRandomizedDesign( [24, 28, 37, 30], # Treatment 1 [37, 44, 31, 35], # Treatment 2 [42, 47, 52, 38], # Treatment 3 ) ``` ``` +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 2 | 450.6667 | 225.3333 | 7.0356 | 0.0145 | | Error | 9 | 288.2500 | 32.0278 | | | | Total | 11 | 738.9167 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ### Example 2 - OneWayANOVA ```py import doex exp = doex.OneWayANOVA( [24, 28, 37, 30], # Treatment 1 [37, 44, 31, 35], # Treatment 2 [42, 47, 52, 38], # Treatment 3 ) ``` ## Randomized Complete Block Design RCBD is equivalent to Two-Way ANOVA. ### Example 1 - RCBD ```py import doex exp = doex.RandomizedCompleteBlockDesign( [ [73, 68, 74, 71, 67], [73, 67, 75, 72, 70], [75, 68, 78, 73, 68], [73, 71, 75, 75, 69], ] ) ``` ``` +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 3 | 12.9500 | 4.3167 | 2.3761 | 0.1211 | | Blocks | 4 | 157.0000 | 39.2500 | 21.6055 | 0.0000 | | Error | 12 | 21.8000 | 1.8167 | | | | Total | 19 | 191.7500 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ### Example 2 - RCBD ```python import doex exp = doex.RandomizedCompleteBlockDesign( [ [9.3, 9.4, 9.6, 10.0], [9.4, 9.3, 9.8, 9.9], [9.2, 9.4, 9.5, 9.7], [9.7, 9.6, 10.0, 10.2], ] ) ``` ``` +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 3 | 0.3850 | 0.1283 | 14.4375 | 0.0009 | | Blocks | 3 | 0.8250 | 0.2750 | 30.9375 | 0.0000 | | Error | 9 | 0.0800 | 0.0089 | | | | Total | 15 | 1.2900 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ### Example 3 - TwoWayANOVA ```python import doex exp = doex.TwoWayANOVA( [ [9.3, 9.4, 9.6, 10.0], [9.4, 9.3, 9.8, 9.9], [9.2, 9.4, 9.5, 9.7], [9.7, 9.6, 10.0, 10.2], ] ) ``` ## Randomized Complete Block Design With Missing Values Missing values must be indicated with `float("nan")`. ### Example 1 - RCBD One Value Missing ```python import doex exp = doex.RandomizedCompleteBlockDesign_MissingValues( [ [18.5, 11.7, 15.4, 16.5], [15.7, float("nan"), 16.6, 18.6], [16.2, 12.9, 15.5, 12.7], [14.1, 14.4, 20.3, 15.7], [13.0, 16.9, 18.4, 16.5], [13.6, 12.5, 41.5, 18.0], ] ) ``` ``` Data after adjusting for 1 missing value(s) [[18.5 11.7 15.4 16.5 ] [15.7 12.92 16.6 18.6 ] [16.2 12.9 15.5 12.7 ] [14.1 14.4 20.3 15.7 ] [13. 16.9 18.4 16.5 ] [13.6 12.5 41.5 18. ]] +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 5 | 120.6883 | 24.1377 | 0.7561 | 0.5956 | | Blocks | 3 | 199.7598 | 66.5866 | 2.0859 | 0.1481 | | Error | 14 | 446.9110 | 31.9222 | | | | Total | 23 | 767.3591 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ### Example 2 - RCBD One Value Missing ```python import doex exp = RandomizedCompleteBlockDesign_MissingValues( [ [90.3, 89.2, 98.2, 93.9, 87.4, 97.9], [92.5, 89.5, 90.6, float("nan"), 87, 95.8], [85.5, 90.8, 89.6, 86.2, 88, 93.4], [82.5, 89.5, 85.6, 87.4, 78.9, 90.7], ] ) ``` ``` Data after adjusting for 1 missing value(s) [[90.3 89.2 98.2 93.9 87.4 97.9 ] [92.5 89.5 90.6 91.08 87. 95.8 ] [85.5 90.8 89.6 86.2 88. 93.4 ] [82.5 89.5 85.6 87.4 78.9 90.7 ]] +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 3 | 166.1438 | 55.3813 | 7.6241 | 0.0029 | | Blocks | 5 | 189.5220 | 37.9044 | 5.2181 | 0.0065 | | Error | 14 | 101.6960 | 7.2640 | | | | Total | 23 | 457.3618 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ### Example 3 - RCBD Two Values Missing ```python import doex exp = doex.RandomizedCompleteBlockDesign_MissingValues( [ [[12, 14, 12], [10, float("nan"), 8], [float("nan"), 15, 10]] ] ) ``` ``` Data after adjusting for 2 missing value(s) [[12. 14. 12.] [10. 12. 8.] [12. 15. 10.]] +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 2 | 12.6667 | 6.3333 | 4.7500 | 0.1739 | | Blocks | 2 | 20.6667 | 10.3333 | 7.7500 | 0.1143 | | Error | 2 | 2.6667 | 1.3333 | | | | Total | 8 | 36.0000 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ## Latin Square Design ### Example 1 - LSD ```py import doex exp = doex.LatinSquare( [ ["A", "B", "D", "C", "E"], ["C", "E", "A", "D", "B"], ["B", "A", "C", "E", "D"], ["D", "C", "E", "B", "A"], ["E", "D", "B", "A", "C"], ], [ [8, 7, 1, 7, 3], [11, 2, 7, 3, 8], [4, 9, 10, 1, 5], [6, 8, 6, 6, 10], [4, 2, 3, 8, 8], ], ) ``` ``` +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 4 | 141.4400 | 35.3600 | 11.3092 | 0.0005 | | Rows | 4 | 15.4400 | 3.8600 | 1.2345 | 0.3476 | | Columns | 4 | 12.2400 | 3.0600 | 0.9787 | 0.4550 | | Error | 12 | 37.5200 | 3.1267 | | | | Total | 24 | 206.6400 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ### Example 2 - LSD With Missing Value Missing values must be indicated with `float("nan")`. ```py import doex exp = doex.LatinSquare( [ ["A", "C", "B", "D"], ["C", "B", "D", "A"], ["B", "D", "A", "C"], ["D", "A", "C", "B"], ], [ [12, 19, 10, 8], [18, 12, 6, float("nan")], [22, 10, 5, 21], [12, 7, 27, 17], ] ) ``` ``` Treatment values after handling 1 missing value at (1, 3): [[12. 19. 10. 8.] [18. 12. 6. 2.] [22. 10. 5. 21.] [12. 7. 27. 17.]] +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Treatments | 3 | 525.5000 | 175.1667 | 12.5119 | 0.0092 | | Rows | 3 | 90.5000 | 30.1667 | 2.1548 | 0.2119 | | Columns | 3 | 48.0000 | 16.0000 | 1.1429 | 0.4168 | | Error | 5 | 70.0000 | 14.0000 | | | | Total | 15 | 734.0000 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ``` ## Graeco-Latin Square Design ```py import doex exp = doex.GraecoLatinSquare( latin=[ ["A", "B", "C", "D", "E"], ["B", "C", "D", "E", "A"], ["C", "D", "E", "A", "B"], ["D", "E", "A", "B", "C"], ["E", "A", "B", "C", "D"], ], greek=[ ["a", "g", "e", "b", "d"], ["b", "d", "a", "g", "e"], ["g", "e", "b", "d", "a"], ["d", "a", "g", "e", "b"], ["e", "b", "d", "a", "g"], ], treatments_values=[ [-1, -5, -6, -1, -1], [-8, -1, 5, 2, 11], [-7, 13, 1, 2, -4], [1, 6, 1, -2, -3], [-3, 5, -5, 4, 6], ], ) ``` ``` +---------------------+-----+----------------+---------------------+-------------+---------+ | Source of Variation | DOF | Sum of Squares | Mean Sum of Squares | F statistic | p value | +---------------------+-----+----------------+---------------------+-------------+---------+ | Latin treatments | 4 | 330.0000 | 82.5000 | 10.0000 | 0.0033 | | Greek treatments | 4 | 62.0000 | 15.5000 | 1.8788 | 0.2076 | | Rows | 4 | 68.0000 | 17.0000 | 2.0606 | 0.1783 | | Columns | 4 | 150.0000 | 37.5000 | 4.5455 | 0.0329 | | Error | 8 | 66.0000 | 8.2500 | | | | Total | 24 | 676.0000 | | | | +---------------------+-----+----------------+---------------------+-------------+---------+ ```