Here is an ANOVA model with one between-subject factor (condition; 4 levels) and one within-subject factor (trial_seq; 20 levels).

amod = aov(decision_quality ~ condition*trial_seq +
       Error(user_id/trial_seq), data = d.task1)

I want to do a pairwise analysis for both the between-subject factor and the within-subject factor. I found that it is not straightforward to use a function like TukeyHSD() for a within-subject factor. I researched this problem and found some suggestions in another thread.

However, my lack of statistical background prevented me from fully understanding vignettes coming with the multcomp package. Anyway, I tried some random statements like:

summary(glht(amod, linfct = mcp(trial_seq = "Tukey")))

However, it generates the following error:

Error in model.matrix.aovlist(model) : 
  ‘glht’ does not support objects of class ‘aovlist’
Error in summary(glht(amod, linfct = mcp(trial_seq = "Tukey"))) : 
  error in evaluating the argument 'object' in selecting a method for     
function 'summary': Error in factor_contrasts(model) : 
  no ‘model.matrix’ method for ‘model’ found!
  • What did I do wrong?
  • $\begingroup$ I found another suggestion at yatani.jp/HCIstats/PostHoc saying simply use pairwise.t.test(decision_quality, trial_seq, p.adj="bonferroni", paired=T) for the post-hoc test of the within-subject factor. I am not sure if this is a correct. $\endgroup$ – jiggysoo Jul 5 '11 at 11:56
  • $\begingroup$ According to uky.edu/ComputingCenter/SSTARS/www/documentation/…, SAS provide the SIMULATE option for general mixed and repeated measures models. Is there anything equivalent in R? $\endgroup$ – jiggysoo Jul 5 '11 at 16:21

As the error message exemplifies, glht does not accept objects of type aovlist. In other words, there is no way of running contrasts with an ANOVA specified via aov.

To achieve what you want you would need to use another way of specifiying the repeated measures ANOVA, namels via lme in the lmer package (using a compound symmteric correlation structure). For a description see my answer to this thread. Because glht can handle lme objects.

If you have problems implementing this procedure please be specific on where your problems are.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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