class: center, middle, inverse, title-slide .title[ # LECTURE 13: factorial designs ] .subtitle[ ## FANR 6750 (Experimental design) ] .author[ ###
Fall 2022 ] --- # outline 1) `\(\large a \times b\)` design <br/> -- 2) Model <br/> -- 3) Procedure <br/> -- 4) Example <br/> -- 5) `\(\large a \times b \times c\)` design --- # factorial designs <br/> #### Often an investigator is interested in the combined effect of two types of treatments <br/> -- #### For example, a study might examine the effects of **predation** and **food supplementation** on *Microtus californicus* abundance <br/> -- #### We "seed" each enclosure with 10 *Microtus* and record the number of voles present after a specified period of time. --- # *microtus californicus* <img src="https://upload.wikimedia.org/wikipedia/commons/d/d4/California_Vole_%28Microtus_californicus%29.jpg" width="90%" height="90%" style="display: block; margin: auto;" /> --- # factorial designs <img src="13_factorial_files/figure-html/unnamed-chunk-2-1.png" width="648" style="display: block; margin: auto;" /> --- # factorial designs - This design differs from blocking designs in that neither of the treatments is considered extraneous to the experimental question (i.e., what controls numbers of voles?) -- - In this case, the experimental unit is an enclosure, and multiple enclosures are represented by and allocated to each combination of the two treatments -- - The treatment variables are called **factors** or main effects, and the different treatments within factors are called **levels** -- - The design is called a factorial design. Here, because there are two factors (predation, food), we will represent them as *A* and *B* and call this an `\(\large a \times b\)` factorial design -- - Because there are `\(\large a = 2\)` levels of predation and `\(\large b = 4\)` levels of food supplementation, this is a `\(\large 2 \times 4\)` factorial design --- # interactions <br/> - We are also usually interested in looking at **interactions**, which is one of the most important notions in ANOVA and experimental design -- - An interaction is an additional effect due to the particular combination of the two levels -- - If an interaction is present, it means that **the effect of one factor depends on the other factor** -- - For example, the effect of predation might depend on the amount of food supplementation --- # interactions Graphically, interactions are indicated by significant departure from parallelism <img src="13_factorial_files/figure-html/unnamed-chunk-3-1.png" width="576" style="display: block; margin: auto;" /> --- ## DATA STRUCTURE FOR `\(\large a \times b\)` FACTORIAL DESIGN <table class="table table-condensed" style="font-size: 14px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="1"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Replicate (k)</div></th> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="1"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Predation (j)</div></th> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="4"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Food supplementation (i)</div></th> </tr> <tr> <th style="text-align:left;"> </th> <th style="text-align:left;"> </th> <th style="text-align:left;"> 0 </th> <th style="text-align:left;"> 1 </th> <th style="text-align:left;"> 2 </th> <th style="text-align:left;"> 3 </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 1 </td> <td style="text-align:left;"> Without </td> <td style="text-align:left;"> \(y_{111}\) </td> <td style="text-align:left;"> \(y_{211}\) </td> <td style="text-align:left;"> \(y_{311}\) </td> <td style="text-align:left;"> \(y_{411}\) </td> </tr> <tr> <td style="text-align:left;"> 2 </td> <td style="text-align:left;"> Without </td> <td style="text-align:left;"> \(y_{112}\) </td> <td style="text-align:left;"> \(y_{212}\) </td> <td style="text-align:left;"> \(y_{312}\) </td> <td style="text-align:left;"> \(y_{412}\) </td> </tr> <tr> <td style="text-align:left;"> 1 </td> <td style="text-align:left;"> With </td> <td style="text-align:left;"> \(y_{121}\) </td> <td style="text-align:left;"> \(y_{221}\) </td> <td style="text-align:left;"> \(y_{321}\) </td> <td style="text-align:left;"> \(y_{421}\) </td> </tr> <tr> <td style="text-align:left;"> 2 </td> <td style="text-align:left;"> With </td> <td style="text-align:left;"> \(y_{122}\) </td> <td style="text-align:left;"> \(y_{222}\) </td> <td style="text-align:left;"> \(y_{322}\) </td> <td style="text-align:left;"> \(y_{422}\) </td> </tr> </tbody> </table> -- Notice that the subscript `\(k\)` represents the replicate for each combination of factors A and B, and there must be replication for each combination of factors -- Also notice that this design is balanced, i.e. there is the same number of replicates (two) for each combination of factors. --- # model `$$\Large y_{ijk} = \mu + \alpha_i + \beta_j + \alpha \beta_{ij} + \epsilon_{ijk}$$` `$$\large \epsilon_{ijk} \sim normal(0, \sigma^2)$$` `$$i = 1, ..., a \;(levels \;of \;factor\;A)$$` `$$j = 1, ..., b \;(levels \;of \;factor\;B)$$` `$$k = 1, ..., n \;(replicates \;of \;each \;combination \;of \;A \;and \;B)$$` - `\(\mu =\)` grand mean - `\(\alpha_i =\)` effect of the `\(i\)`th level of food supplementation - `\(\beta_j =\)` effect of the `\(j\)`th level of predator exclusion - `\(\alpha \beta_{ij} =\)` effect of interaction of `\(i\)`th level of food and `\(j\)`th level of predation - `\(\epsilon_{ijk} =\)` residual, unexplained variation --- # hypotheses #### Factor A `$$H_0 : \alpha_1 = \alpha_2 = ... = \alpha_a = 0$$` `$$H_a : At \;least \;one \;inequality$$` #### Factor B `$$H_0 : \beta_1 = \beta_2 = ... = \beta_b = 0$$` `$$H_a : At \;least \;one \;inequality$$` -- #### Interaction of factors A & B `$$H_0 : \alpha\beta_1 = \alpha\beta_2 = ... = \alpha\beta_{ij} = 0 \;for \;all \;ij$$` `$$H_a : At \;least \;one \;inequality$$` -- Technically, we could treat each of the effects as fixed or random, although it is much more common to use fixed effects in factorial designs --- # anova table <br/> <table class="table table-condensed" style="font-size: 18px; width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:center;"> Source </th> <th style="text-align:center;"> df </th> <th style="text-align:center;"> SS </th> </tr> </thead> <tbody> <tr> <td style="text-align:center;"> Factor A </td> <td style="text-align:center;"> \(a-1\) </td> <td style="text-align:center;"> \(bn \sum_i (\bar{y}_{i..} - \bar{y}_{...})^2\) </td> </tr> <tr> <td style="text-align:center;"> Factor B </td> <td style="text-align:center;"> \(b-1\) </td> <td style="text-align:center;"> \(an \sum_j (\bar{y}_{.j.} - \bar{y}_{...})^2\) </td> </tr> <tr> <td style="text-align:center;"> A x B </td> <td style="text-align:center;"> \((a-1)(b-1)\) </td> <td style="text-align:center;"> \(n \sum_i \sum_j (\bar{y}_{ij.} - \bar{y}_{i..} - \bar{y}_{.j.} + \bar{y}_{...})^2\) </td> </tr> <tr> <td style="text-align:center;"> Error </td> <td style="text-align:center;"> \(ab(n-1)\) </td> <td style="text-align:center;"> \(\sum_i \sum_j \sum_k (y_{ijk} - \bar{y}_{ij.})^2\) </td> </tr> </tbody> </table> -- #### What are the associated mean squares and F statistics? --- # more on interactions #### If an interaction is significant, then the effect of one factor depends on the other factor -- #### Thus, if an interaction is significant, then usually it is ill-advised to further investigate main effects alone (such as with multiple comparison procedures) without taking the other factor into account -- #### The way that you do this is to perform a multiple comparison test for one factor at each level of the other factor, and vice versa -- #### This is easily performed in `R` as we will see in lab --- class: inverse, center, middle # example --- # analysis of (fake) *microtus* data #### Data are voles per enclosure <table class="table" style="font-size: 14px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="1"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Replicate (k)</div></th> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="1"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Predation (j)</div></th> <th style="border-bottom:hidden;padding-bottom:0; padding-left:3px;padding-right:3px;text-align: center; " colspan="3"><div style="border-bottom: 1px solid #ddd; padding-bottom: 5px; ">Food supplementation (i)</div></th> </tr> <tr> <th style="text-align:left;"> </th> <th style="text-align:left;"> </th> <th style="text-align:right;"> 0 </th> <th style="text-align:right;"> 1 </th> <th style="text-align:right;"> 2 </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 1 </td> <td style="text-align:left;"> With </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 18 </td> <td style="text-align:right;"> 20 </td> </tr> <tr> <td style="text-align:left;"> 2 </td> <td style="text-align:left;"> With </td> <td style="text-align:right;"> 12 </td> <td style="text-align:right;"> 20 </td> <td style="text-align:right;"> 18 </td> </tr> <tr> <td style="text-align:left;"> 3 </td> <td style="text-align:left;"> With </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 21 </td> <td style="text-align:right;"> 14 </td> </tr> <tr> <td style="text-align:left;"> 4 </td> <td style="text-align:left;"> With </td> <td style="text-align:right;"> 14 </td> <td style="text-align:right;"> 24 </td> <td style="text-align:right;"> 16 </td> </tr> <tr> <td style="text-align:left;"> 1 </td> <td style="text-align:left;"> Without </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 22 </td> <td style="text-align:right;"> 42 </td> </tr> <tr> <td style="text-align:left;"> 2 </td> <td style="text-align:left;"> Without </td> <td style="text-align:right;"> 12 </td> <td style="text-align:right;"> 28 </td> <td style="text-align:right;"> 40 </td> </tr> <tr> <td style="text-align:left;"> 3 </td> <td style="text-align:left;"> Without </td> <td style="text-align:right;"> 14 </td> <td style="text-align:right;"> 36 </td> <td style="text-align:right;"> 44 </td> </tr> <tr> <td style="text-align:left;"> 4 </td> <td style="text-align:left;"> Without </td> <td style="text-align:right;"> 18 </td> <td style="text-align:right;"> 40 </td> <td style="text-align:right;"> 42 </td> </tr> </tbody> </table> --- # analysis of (fake) *microtus* data ```r data("microtusData") microtusData$food <- as.factor(microtusData$food) aov1 <- aov(voles ~ food*predators, data = microtusData) summary(aov1) ``` ``` ## Df Sum Sq Mean Sq F value Pr(>F) ## food 2 1337 669 40.6 2.1e-07 *** ## predators 1 975 975 59.2 4.3e-07 *** ## food:predators 2 518 259 15.7 0.00011 *** ## Residuals 18 297 16 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ``` --- # analysis of (fake) *microtus* data ```r newDat <- data.frame(food = rep(c("0", "1", "2"), 2), predators = rep(c("Present", "Absent"), each = 3)) pred <- predict(aov1, newdata = newDat, se.fit = TRUE, interval = "confidence", level = 0.95) pred$fit ``` ``` ## fit lwr upr ## 1 11.00 6.735 15.27 ## 2 20.75 16.485 25.02 ## 3 17.00 12.735 21.27 ## 4 13.50 9.235 17.77 ## 5 31.50 27.235 35.77 ## 6 42.00 37.735 46.27 ``` --- # analysis of (fake) *microtus* data <img src="13_factorial_files/figure-html/unnamed-chunk-8-1.png" width="576" style="display: block; margin: auto;" /> --- ## `\(\large a \times b \times c\)` DESIGN - The `\(\large a \times b\)` factorial design can be extended to three or more factors -- - Development of Sums of Squares, degrees of freedom, etc. are natural extensions of what we have learned before, but we will not cover them in this course. See Quinn et al. if you are interested in the details -- - If the three-way interaction is significant, then the effect of one factor is dependent upon the particular levels of both of the other factors -- - In practice, one could try to tease apart these relationships as we discussed previously for the two-way design. However, interpretation of these results gets confusing -- - A much more effective approach is to present the results graphically (means and standard errors or confidence intervals) as we did before with the vole example. This will necessitate more than one graph --- # army ants Roberts et al. (2000)\* followed randomly selected army ant swarms of two species (*Eciton burchellii* and *Labidus praedator*) in two habitats (shade coffee plantations and primary forest) in two seasons (dry and wet) in western Panama -- Of the two species, *E. burchellii* is larger and spends most of its time above ground in bivouacs or swarming, whereas *L. praedator* is smaller and spends much of its time below ground, although it also swarms above ground. The response variables were number of birds attending the swarms (to capture flushed arthropods) and the number of bird species attending the swarms -- This was set up as a three-way factorial design ??? `\(^*\)`Roberts, D. L., Cooper, R. J., & Petit, L. J. (2000). Flock characteristics of antâfollowing birds in premontane moist forest and coffee agroecosystems. *Ecological Applications*, 10(5), 1414-1425. --- # army ants .pull-left[ <br/> <img src="https://upload.wikimedia.org/wikipedia/commons/d/d3/Eciton_burchellii_army_ants.jpg" style="display: block; margin: auto;" /> ] .pull-right[ <img src="https://upload.wikimedia.org/wikipedia/commons/7/74/Ocelated_Antbird_%2839995295545%29.jpg" style="display: block; margin: auto;" /> ] --- # army ants .pull-left[ <iframe width="560" height="315" src="https://www.youtube.com/embed/iDIyGSOdTys" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> ] .pull-right[ <iframe width="560" height="315" src="https://www.youtube.com/embed/UozWJTuhbMQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> ] --- # army ants <br/> <img src="figs/Image 7-6-21 at 11.15 AM.png" width="353" style="display: block; margin: auto;" /> --- # army ants The three-way interaction was significant for both richness ( `\(F_{1,133} = 6.05\)`, `\(P = 0.02\)`) and abundance ( `\(F_{1, 133} = 7.19\)`, `\(P = 0.008\)`) -- In the dry season, there were more birds in the forest than in coffee at *L. praedator* swarms, but not at *E. burchelli* swarms -- In the change to wet season in the spring, which also corresponded to a time when neotropical migrants left to migrate north, birds declined at all swarms except *E. burchelli* swarms in forest, where there were more obligate ant-following birds that tracked the locations of this larger, above-ground species --- # summary - Factorial designs let you test the effects of > 1 treatment variable -- - It's important to always assess the interaction first, before assessing main effects -- - If the interaction is significant, then the effect of one factor depends on the other, so they can't be interpreted in isolation -- - Factorial designs are extremely powerful but hard to pull off when there are more than 2 factors (with many levels per factor) -- - But you should try anyway!