I've been looking into using planned contrasts as opposed to post-hoc t-tests. I typically use ezANOVA
(Type III ANOVA) but it seems that conducting planned contrasts using ezANOVA
is not currently catered for.
aov()
on the other hand is a Type I ANOVA (I don't want to get into a debate about which type is best for which type of design). It is straight forward to conduct planned contrasts using aov()
(for between group designs) but I want to conduct a Type III ANOVA in a repeated measures and to be frank ezANOVA
has a much more user friendly output.
Bearing in mind ezANOVA
has the option to include return_aov = TRUE
does anyone know of a way to use the information provided by ezANOVA
to conduct planned contrasts?
Note: return_aov = TRUE
allows access to the output of aov
via something along these lines:
summary.lm(ModelName$aov$'Participant:IndependentVariable1')
Participant above is an example variable added to wid
in ezANOVA
:
wid = .(Participant)
summary.lm()
is typically used when presenting the results of planned contrasts in aov
, granted between groups ANOVAs as opposed to repeated measures.
I'm particularly interested in using the output to conduct planned contrasts for repeated measures ANOVA.
BOUNTY GOALS
Goals I would like to achieve from this bounty:
1) Use the output of ezANOVA
to conduct planned contrasts in a repeated measures ANOVA.
1A) Use the output of ezANOVA
to conduct planned contrasts on between subjects ANOVA (this one should be relatively easy & therefore not a requisite to claim the bounty.)
Any dummy data should suffice but here is a reminder of the format for ezANOVA
repeated measures ANOVA:
ModelName <- ezANOVA(
data = DataSet,
dv = .(DependentVariable),
wid = .(Participant),
within = .(IndependentVariable1, IndependentVariable2),
type=3,
detailed = TRUE,
return_aov = TRUE)
This is a Related Question with reproducible data and code which can be used in relation to this problem.
You can find a PDF here giving some background on planned contrasts and what they do.
The
emmeans
package provides the appropriate functionality to calculate custom contrasts/arbitrary linear functions of the estimates marginal means (EMMs) foraov
andaovlist
objects (see here for a full list of supported models).In the following I use the
ANT
data set which comes with theez
package.First we set up a mixed factorial ANOVA using
ezANOVA
. Note that one needs to set orthogonal contrasts in order to get meaningful Type-III tests (see, e.g., John Fox' answer here).We can then calculate the EMMs for, say all group-flank combinations.
Now it is easy to calculate all pairwise comparisons or any desired contrast on these EMMs.
See also this book chapter and my answer here if you need a bit more detail on how one can derive the contrasts weights from the hypotheses.
The same applies for purely within-subjects ANOVAs or between-subjects ANOVAs.