# Post-hoc tests for 2x2 ANOVAs (Type II & III) with interactions in R

I am trying to analyze data from an experiment using R and ran across a problem regarding the use of post-hoc tests with Type II & III ANOVAs. I only know of R functions that perform post-hoc tests based on Type I SS, such as TukeyHSD and glht. Others, such as HSD.test from the agricolae package do not seem to calculate tests for interactions. Do post-hoc tests that also test for interaction terms exist for R that enable the use of Type II & III SS ANOVAs? Alternatively, is there a way to convert Anova objects (Type II or III, car package) to aov objects in order to use them with the TukeyHSD function?

• Tests are useless (and puzzling), rather use confidence intervals, and you'll not have "type" problems. Oct 15 '14 at 11:37

If you really mean 2x2 as in "two factors, each at two levels" there is hardly a need for post hoc anything, because there is 1 df for each main effect and 1 df for interaction. You wouldn't use Tukey HSD for this, and if you used it, it'd be the same as the regular unadjusted tests because there is only one comparison in each family. But let me know if I misunderstand something. You might want to look at the lsmeans package and see if it offers the kind of comparisons you need.

• Thanks. I need to use the Tukey test in order to see which combinations of factor levels are significally different in interactions. For some calculations, I need to add covariates or perform 2x2x2 analyses, so I need the Tukey test (or at least the Bonferroni or Holm test) to work with my data. I have also tried the lsmeans package and although it works well with my data, I could not find any information on which SS type it uses (since it is used with lm objects, not Anova or aov objects whose SS type you can choose) or how this can be set.
– user55987
Sep 18 '14 at 13:40
• I think you are confused about the role of sums of squares types. Those have only to do with ANOVA F tests, determining which model you are comparing with which other model. They have nothing to do with estimating linear functions of regression coefficients. The full model's error structure is always the reference for obtaining the standard errors of these estimates. Sep 18 '14 at 14:51
• Oh, I see. I am indeed not very familiar with the different SS types (coming from SPSS I never had to worry about that) but I read on statmethods.net/stats/anova.html (section "Multiple Comparisons") that the results of post-hoc tests are based on the fit supplied by the aov function, which would differ if I used different SS types in the ANOVA. Does what you said entail that I can use whichever post-test function I wish?
– user55987
Sep 18 '14 at 15:44
• OK, well I looked at the site you mention and it does indeed say that the TukeyHSD results are based on type I SS. But I have no idea what he means by that. Maybe somebody else can set us straight. Perhaps he means that aov provides for multiple error strata, and those are computed sequentially (as are type I SS). But iF you have a mixed model, I suggest you use lmer (lme4 package) instead of aov, especially with covariates, because aov is really designed for traditional balanced experimental designs with no covariates. Sep 18 '14 at 20:12

I'm not a stats or R pro, so maybe someone might want to confirm this, but the lsmeans package in combination with the multcomp package indeed helped me to analyze the significant interactions of my lmer-Model (see here, if you want to have a look whether it compares to your problem):

summary(glht(model, lsm(pairwise ~ factorB | factorA)))


This tells me for each level of factor A whether the levels of factor B differ significantly. According to the help page of lsmeans, it's supposed to be an S3-method.