I have a mixed model of the form y~condition + Replicate + Error(Replicate) but at the moment, and am running into difficulties in performing a post-hoc test.

I know there is no best option and it entirely depends on experimental design and the characteristics of my data, so I am hoping to find out a few options that I should investigate and attempt to implement.

In the past I have used Tukey Kramer and Dunnet using R and glht i.e. glht(model, linfct=mcp(Group="Dunnett")) but at this time I have to stay with aov() which unfortunately the glht function can't accept as in input model, and aov() can't apply more than a single layer of variables to it's multiple comparisons i.e. can't use this multiple comparison to account for my random effect.

  1. If anyone knows of a multiple comparisons package that can do a post-hoc test compatible with the aov() model I would love to give it a try.

  2. If anyone can recommend some post-tests that can be used to make my p-value a little less conservative I would also be interested to investigate it. The usual p-value adjustment tests don't seem to be quite suitable because of the semi-continuous nature of the point sampling (These aren't quite discrete groups which makes the length variable impossible to determine. ANOVA P-value adjustments for semi-continuous data)

  • $\begingroup$ I don't really understand point 2, even after looking at the link you provide. What 'length' variable? Is it 'condition' that is semi-continuous? Say more about this point sampling and how it relates to the factors in the experiment. $\endgroup$
    – Russ Lenth
    Jan 17, 2015 at 22:05
  • $\begingroup$ @rvl the length variable is a notation I adopted from "n number of comparisons, must be at least length(p); only set this (to non-default) when you know what you are doing!" - stat.ethz.ch/R-manual/R-devel/library/stats/html/p.adjust.html $\endgroup$
    – EngBIRD
    Jan 17, 2015 at 22:09
  • $\begingroup$ Well this seems problematic, then, because you're worried about the adjustment being too conservative, and n must be at least equal to the number of P values being considered. You can only increase n, so you can only make it MORE conservative. But in a way that's beside the point. I still don't understand why you think it's too conservative, or what error rate you are trying to control. $\endgroup$
    – Russ Lenth
    Jan 17, 2015 at 22:18

1 Answer 1


The lsmeans package does support aovlist objects, but you should do something like options(contrasts="contr.sum","contr.poly") before fitting the model, to ensure the dummy variables for factors sum to zero. This is necessary because the intercept is put in a separate stratum and we want the rest of the effects to be orthogonal to it. You can then do something like

( mod.lsm = lsmeans(model, "condition") )
contrast(mod.lsm, "trt.vs.ctrl")

If your data are unbalanced, though, I'd suggest you install the lme4 package, and fit your model using lmer with a model like y ~ condition + (1 | Replicate), which is the analogous model. The above statements still work exactly as shown, without the need to change the contrasts options. In the contrast call, there are several other options such as "pairwise" in case you don't want Dunnett style contrasts.

  • $\begingroup$ Would you per chance know what the lmer equivalent of y~condition + Replicate + Error(Replicate) is it close to Y ~ Condition + (1 | Condition:Replicate) I believe the : implies nested but I do not want a nested variable and I am not sure how to keep it additive. $\endgroup$
    – EngBIRD
    Jan 17, 2015 at 22:52
  • $\begingroup$ Yes: the last term would just be (1|Replicate). $\endgroup$
    – Russ Lenth
    Jan 17, 2015 at 22:55
  • $\begingroup$ Is it to be expected that the results of Aov and lmer don't quite match up? Thanks! $\endgroup$
    – EngBIRD
    Jan 18, 2015 at 3:30
  • $\begingroup$ If there is a term in more than one stratum, yes. $\endgroup$
    – Russ Lenth
    Jan 18, 2015 at 5:43
  • $\begingroup$ I don't follow quite how stratified sampling will have an effect. The way I understand my data's factors there is no way for a data point to belong to more than one group... What would be the best way to use the outputs to back track for this. I notice that the summary models for aov and lmer have different DOF. $\endgroup$
    – EngBIRD
    Jan 18, 2015 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.