More Linear Models
Get introduced to a multitude of linear models.
Multi-way ANOVA
Is it possible to use the glht()
or emmeans()
functions described in the Multiple Comparisons lesson to perform post-hoc tests and understand which of our six treatment combinations are significantly different from one another? The answer is both yes and no. First, we can use either function to look at the effect of one predictor while averaging across the levels of the other predictor. However, that may not be what we want to do, especially when we have significant interaction.
Post-hoc comparisons when we have interactions
Using emmeans()
allows us to specifically look at one predictor across the levels of the other predictor, which is pretty useful. In the following code, we conduct Tukey’s ‘honestly significant differences’ (HSD) post-hoc test, which compares each factor level against all other levels. We specify which predictor we want to look for differences in with the specs=
argument. We can tell the model to run the Tukey test separately for each level of a separate predictor with the by=
argument.
Now, we have a choice to make. Should we analyze the effect of the three predator treatments within the two resource treatments, or should we see what effect the resource levels have within each predator treatment? Although, in reality, we’d want to choose one approach or the other, here we can perform both and see what they tell us about the data.
First, let’s see how predators affected the age at metamorphosis within each resource level.
#Use the ’by=’ argument to do post-hoc tests for one#factor within each of the levels of the other factorph2<-emmeans(lm2, specs="Pred", by="Res")pairs(ph2)
This output ...