I'm dealing with an unbalanced design/sample and originally learned aov()
. I know now that for my ANOVA tests I need to use the Type III Sum of Squares which involves using fitting using lm()
rather than using aov()
.
The problem is getting post-hoc tests (specifically Tukey's HSD) using lm()
. All the research I've done has said that using simint
in the multcomp
package would work, but now that it's updated that command seems to not be available. It also seems to rely upon going through aov()
to calculate.
Essentially all of the Tukey HSD tests I've found for R assume that you use aov()
for the comparison rather than lm()
. To get the Type III Sum of Squares I need for the unbalanced design I have to use:
mod<-lm(Snavg~StudentEthnicity*StudentGender)
Anova(mod, type="III")
How do I use a Tukey HSD test with my mod using lm()
? Or conversely, calculate my ANOVA using Type III and still be able to run a Tukey HSD test?
Thanks!
Try HSD.test
in agricolae
library(agricolae)
data(sweetpotato)
model<-lm(yield~virus, data=sweetpotato)
comparison <- HSD.test(model,"virus", group=TRUE,
main="Yield of sweetpotato\nDealt with different virus")
Output
Study: Yield of sweetpotato
Dealt with different virus
HSD Test for yield
Mean Square Error: 22.48917
virus, means
yield std.err replication
cc 24.40000 2.084067 3
fc 12.86667 1.246774 3
ff 36.33333 4.233727 3
oo 36.90000 2.482606 3
alpha: 0.05 ; Df Error: 8
Critical Value of Studentized Range: 4.52881
Honestly Significant Difference: 12.39967
Means with the same letter are not significantly different.
Groups, Treatments and means
a oo 36.9
ab ff 36.33333
bc cc 24.4
c fc 12.86667