class: center, middle, inverse, title-slide .title[ # LECTURE 12: fixed effects and random effects ] .subtitle[ ## FANR 6750 (Experimental design) ] .author[ ###
Fall 2022 ] --- # outline <br/> 1) Motivation <br/> -- 2) Random effects in one-way ANOVA <br/> -- 3) Random effects in blocked ANOVA --- # motivation #### The completely randomized ANOVA we have discussed can be applied to many different experiments. For example, it could be used to: - Assess the best option from two different pesticides (plus no spray) used for gypsy moth control - Assess if there is significant variability among the test scores of introductory statistics classes when taught by different instructors -- #### In the first example, we would model the effect of each pesticide as a fixed effect -- #### In the second example, the effect of each instructor would be modeled as a random effect --- # fixed vs random effects <br/> #### A fixed effects model is appropriate when the treatment levels included in the experiment are exhaustive <br/> -- #### A random effects model is appropriate when the treatment levels in the experiment can be considered a sample from a larger population of interest - In the previous example, we are interested in all instructors, not just the ones included in the experiment --- # models ### Fixed-effects model `$$\Large y_{ij} = \mu + \alpha_i + \epsilon_{ij}$$` `$$\Large \epsilon_{ij} \simnormal(0, \sigma^2)$$` -- ### Random-effects model `$$\Large y_{ij} = \mu + \alpha_i + \epsilon_{ij}$$` `$$\Large \alpha_{i} \simnormal(0, \sigma_A^2)$$` `$$\Large \epsilon_{ij} \simnormal(0, \sigma^2)$$` -- In a random effects model, the effects are assumed to be random variables following some probability distribution --- # hypotheses #### In a random-effects model, our interest is in assessing how much variation there is among all the effects in the population, not just the ones in our sample #### As a result, our hypotheses must be written differently: -- #### Fixed-effects model `$$\large H_0 : \alpha_1 = \alpha_2 = ... = \alpha_a = 0$$` `$$\large H_a : At\;least\;one\;inequality$$` -- #### Random-effects model `$$\large H_0 : \sigma^2_A = 0$$` `$$\large H_a : \sigma^2_A > 0$$` --- # implications? #### Oddly enough, in the context of a one-way ANOVA, the analysis procedure is exactly the same for the fixed-effects and random-effects models -- #### In other words, we can construct the ANOVA table and test the null hypothesis using the same procedure for the random-effects model as we used for the fixed-effects model, even though the interpretation of the results is slightly different -- #### A comprehensive list of the distinctions between the two approaches is given in section 8.2 of Quinn et al. -- #### The distinction between random and fixed effects becomes much more important in the more complicated models that we will cover soon --- class: inverse, center, middle # random effects in blocked anova --- # blocked anova <br/> ### Should we treat block effects as fixed or random? <br/> -- ### As before, we need to answer the question: > Can we view the blocks as samples of a larger population, or do the blocks represent all possible levels? --- # random effects model for blocked design `$$\huge y_{ij} = \mu + \alpha_i + \beta_j + \epsilon_{ij}$$` `$$\Large \beta_{j} \sim normal(0, \sigma^2_B)$$` `$$\Large \epsilon_{ij} \sim normal(0, \sigma^2)$$` <br/> -- #### This is often called a mixed effects model because it includes fixed and random effects -- #### If we treated the `\(\alpha\)`'s as random too, we might call the model a *variance components model* --- # hypotheses .pull-left[ #### Main hypothesis `$$H_0 : \alpha_1 = \alpha_2 = ... = \alpha_a = 0$$` `$$H_a : At\;least\;one\;inequality$$` OR `$$H_0 : \sigma^2_A = 0$$` `$$H_a : \sigma^2_A > 0$$` ] -- .pull-right[ #### Secondary hypothesis `$$H_0 : \beta_1 = \beta_2 = ... = \beta_b = 0$$` `$$H_a : At\;least\;one\;inequality$$` OR `$$H_0 : \sigma^2_B = 0$$` `$$H_a : \sigma^2_B > 0$$` ] --- # implications <br/> <br/> #### Once again, treating block effects as random doesn't affect our calculations for the ANOVA table<sup>1</sup> - it only affects the interpretation .footnote[<sup>1</sup> Technically, this is only true for balanced designs] --- # random-effects model in `r` ```r aov1 <- aov(caterpillar ~ Treatment + Region, mothData) summary(aov1) ``` <table class="table table-condensed" style="font-size: 10px; width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> term </th> <th style="text-align:right;"> df </th> <th style="text-align:right;"> sumsq </th> <th style="text-align:right;"> meansq </th> <th style="text-align:right;"> statistic </th> <th style="text-align:right;"> p.value </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Treatment </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 223.2 </td> <td style="text-align:right;"> 111.58 </td> <td style="text-align:right;"> 5.830 </td> <td style="text-align:right;"> 0.0392 </td> </tr> <tr> <td style="text-align:left;"> Region </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 430.9 </td> <td style="text-align:right;"> 143.64 </td> <td style="text-align:right;"> 7.505 </td> <td style="text-align:right;"> 0.0187 </td> </tr> <tr> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 114.8 </td> <td style="text-align:right;"> 19.14 </td> <td style="text-align:right;"> </td> <td style="text-align:right;"> </td> </tr> </tbody> </table> -- ```r aov2 <- aov(caterpillar ~ Treatment + Error(Region), mothData) summary(aov2) ``` <table class="table table-condensed" style="font-size: 10px; width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> stratum </th> <th style="text-align:left;"> term </th> <th style="text-align:right;"> df </th> <th style="text-align:right;"> sumsq </th> <th style="text-align:right;"> meansq </th> <th style="text-align:right;"> statistic </th> <th style="text-align:right;"> p.value </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Region </td> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 430.9 </td> <td style="text-align:right;"> 143.64 </td> <td style="text-align:right;"> </td> <td style="text-align:right;"> </td> </tr> <tr> <td style="text-align:left;"> Within </td> <td style="text-align:left;"> Treatment </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 223.2 </td> <td style="text-align:right;"> 111.58 </td> <td style="text-align:right;"> 5.83 </td> <td style="text-align:right;"> 0.0392 </td> </tr> <tr> <td style="text-align:left;"> Within </td> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 114.8 </td> <td style="text-align:right;"> 19.14 </td> <td style="text-align:right;"> </td> <td style="text-align:right;"> </td> </tr> </tbody> </table> --- # summary - We usually model the main treatment effects as fixed, but sometimes we are interested in effects not in the sample -- - Random effects models allow for inference about entire population of effects -- - Random effects models make additional distributional assumptions -- - Usually, you need many treatment levels (5-10) to get a decent estimate of the variance parameter associated with the random effects -- - In spite of the big conceptual differences, the procedures aren't much different for one-way and blocked ANOVAs