# Post Hoc Tests – Pairwise Comparisons with corrections

The function `pairwise.t.test()` allows for performing multiple t-tests on a multitude of groups using all possible pairwise comparisons. This comes handy as a follow up to one-way ANOVA, two-way ANOVA, … In addition, these pairwise t-tests assume normality of distribution and equality of variances which you needed anyway to perform ANOVA.

This function is rather simple: the syntax is `pairwise.t.test(data, groups, p.adjust.method= )` where `data` is the vector containing your dependent variable and `groups` is the vector containing the grouping factor. In addition, `pairwise.t.test()` allows you to apply the method of your choice when it comes to correcting/adjusting p-values to control type I errors. Simply add the name or abbreviation for the method to the argument `p.adjust.method=`. The methods are `none` (no correction), `bonferroni`, `holm`, `hochberg`, `hommel`, `BH` and `BY`. Choosing the right correction for your analysis depends a lot on your experimental design… and certainly a bit in you wish to find lower p-values at the cost of making type I errors…

Let’s the example from one-way ANOVA where the dataframe and ANOVA where coded the following way:

```size<-c(25,22,28,24,26,24,22,21,23,25,26,30,25,24,21,27,28,23,25,24,20,22,24,23,22,24,20,19,21,22)
location<-c(rep("ForestA",10), rep("ForestB",10), rep("ForestC",10))
my.dataframe<-data.frame(size,location)
results<-aov(size~location, data=my.dataframe)
summary(results)
```

Now let’s look at 3 cases of post hoc pairwise t-tests, the first one without correction, the second one with bonferroni correction and the last one with hochberg correction:

```