##### Copter ANOVAs I # Experimental design and analysis must match. # If they don't match we risk making wrong conclusions about the results. # This occurs more often in science than we wish to admit. # Today we run various analyses that do not fully match the complex experimental design for the helicopters data. # Next week, we will analyze the results in the full, correct way and compare those results to today's results. # So save your results today – you will need to look at them again next week. # A reminder: the experiment used three treatments to potentially affect helicopter flight times: # a. wing length # b. body width # c. whether wings included a fold or not. # Today we treat each of these as separate treatments – in reality the experiment investigated the interactions of the 3 treatments. # We ignore interactions today !warning! !warning!; there is already a mismatch between design and analyses - do you see why? ##### R Steps to follow: # 1. Import and attach the copter data from # https://sciences.ucf.edu/biology/d4lab/wp-content/uploads/sites/23/2021/09/helicopter-data.csv # Below I assume you called this "data" for simplicity. # 2. In case there are any NAs, it may be helpful to remove them with a command like this: data <- na.omit(data) attach(data) # You have already examined normality of these data. To save time right now, let's *assume* that # normality is not too far out of whack. But you also should already expect the other key # assumption (homogeneous variance) to be a big problem. This is more critical for ANOVAs than normality so let’s revisit: # 3. First make a factor for each of ID, Wing Length (WL) and Body Width (BW): fid <- factor(ID) # where ID indicates a unique design - i.e., a unique WL & BW and fold combination. fwl <- factor(WL) fbw <- factor(BW) ffold <- factor(Fold) # Then run a Levene's test by first loading the package “car” and then running: leveneTest(Time~fid) # NOTE: This is a shortcut – using IDs for all combinations of wing length, fold, and body width. # Are the variances among each design about the same? # If so, then we can use ANOVA with confidence. # If not, then all we do below is on shaky ground. # And iterative attempts to transform data may not help. # This SHOULD be a big red flag to you! Beware of analyses with bad assumptions! # 4. Let's stumble ahead anyway just so you can see how to conduct an ANOVA. We will first use Wing Length (WL), in two ways: # The first reports results as a simple ANOVA, with the expectation that treatments are categorical. # The second produces regression output, with the expectation that treatments are quantitative. model1 <- aov(Time ~ fwl) # an ANOVA on factored WL - to make WL categories model2 <- lm(Time ~ WL) # a linear model on quantitative WL summary(model1) summary(model2) # What does the aov output show you that the lm command does not? # Vice versa - What does the lm output show you that the aov command does not? # Do you get different answers? [Hint: look at F statistics] # 5. Now rename and repeat those analyses but use Fold in place of WL # (I assume you call those model3 & model4). How does this compare to WL outcomes? # Now you are starting to compare the relative effects of folds and wing lengths. # 6. Now rename and repeat those analyses but use BW in place of Fold # (I assume you call those model5 & model6). # How does this compare to above outcomes? # Do you see a problem with evaluating these effects (WL, Fold, BW) *separately*? You should! # 8. Now let's get into details. How much of the variation in flight times is explained by WL, Fold, or BW? # How can you tell? Is this satisfactory? # 9. Now let's try a factorial statement that starts to represent the complex experiment. # So far we have only analyzed pieces that do not fully represent the whole. A factorial design # allows us to examine the effects of one factor on the effects of a second factor. Our # factorial experiment answers the question: “Does the effect of wing length on flight time # depend on whether wings are folded and body width?” # Alternatively: “Does the effect of folded wings on flight time depend on wing length and folds?” model7 <- aov(Time ~ fwl*fbw*ffold) model8 <- lm(Time ~ WL*BW*ffold) # why use quantitative WL and BW here but use the factored ffold? summary(model7) summary(model8) # NOTE: R knows when you enter A*B that you mean this: [A + B + A X B]. # So you will be able to evaluate each effect and the interaction. # Look at the ANOVA results (model 7) first: Did treatments clearly affect flight time, and did # treatments affect each other's flight time? Which effect seems most important? # If there are significant interaction effects, that is the focus; separate effects of each treatment # in an interaction are no longer solo. Instead, the effect of one on the other must be considered. # Now let's examine the linear model (lm) results: notice that the rows are named # differently? This takes a moment's thought because now we see an intercept – what is this? # And what do the something:something lines tell you? # 10. Let's make an interaction graph to help interpret this. Enter this command: interaction.plot(Fold, trace.factor=fwl, response=Time, fun=mean, type="b") # Do longer Wings make copters stay in the air longer? How do you know? # Do folded Wings alter that effect of Wings? How do you know? # How would you explain this in a few sentences that would convince your advisor? # So what have we accomplished? # We computed a factorial ANOVA to find out if there was an interaction between three experimental treatments. # We can compare SS & MS in the ANOVA table to see which treatment had a greater effect. # But that basic ANOVA leaves us wishing for more details. And lm output gave us that. # The lm output and the interaction plot allow us to tease apart what happened, and to # quantify those effects. We will refine this later. # One final question: how much variation in helicopter flight times did we # account for with our most recent model? Does this seem like enough? # Next week we fully account for Group effects and the covariate of Stairs.