0

I'm attempting a two way ANOVA in R using the Anova function from the car package (so I can specify that it is a type II ANOVA).

For example

model <- lm(formula = response ~ treatment * species, data = data)

model2 <- car::Anova(model, type = 2)

Example data:

data1 <- data.frame(species = c("1","1","1","1","1","1","1","1","1","1","2","2","2","2","2","2","2","2","2","2"), 
                    treatment = c("a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b"),
                    response = c(6,5,7,8,9,4,3,5,6,9,3,6,6,7,8,9,5,6,7,8))

I then would like to run a post-hoc test on model2 to determine which pairs are significantly different from each other. I'd like to get the p values for all combinations of treatments and species (ex. treatment a/species 1 compared to treatment b/species 1 and treatment b/species 2 and so on) and also the connecting letter report.

None of the functions/packages I've tried (HSD.test, TukeyHSD) seem to work on a car::Anova object. Furthermore, HSD.test requires that you choose one of the factors for the Tukey's test and will not run on interacting factors.

Is there a package anyone can recommend that will both work with car::Anova and run on multiple factors, that gives you the connecting letter report?

Thanks!

I've tried HSD.test and TukeyHSD.

neilfws
  • 32,751
  • 5
  • 50
  • 63
mels
  • 15
  • 4
  • It's easier to help if you [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including a small representative dataset in a plain text format - for example the output from `dput(data)`, if that is not too large. – neilfws Aug 22 '23 at 04:22
  • 1
    ok thanks I tried adding some example data – mels Aug 22 '23 at 04:34
  • 3
    Fit a type 1 model with `aov` and pass that to `TukeyHSD`. The type of ANOVA has no impact on the test. – Roland Aug 22 '23 at 05:20
  • ok thanks I didn't realize that it didn't matter- thank you – mels Aug 22 '23 at 23:24

0 Answers0