## Learning Outcomes

By the end of this section, students will be able to:

- Explain when and how to use post hoc testingÂ
- Explain the concept of multiple comparisons and be able to correct for it in their analysis
- Explain when and how to use repeated measures statistics
- Apply extensions to the basic ANOVA test and interpret their results

You can download a copy of the slides here: B2.2a Correcting for Multiple Comparisons

## B2.2a PRACTICAL: ALL

**False Discovery Rate**

To use this method, we must first assign a value for q. Whereas Î± is the proportion of false positive tests we are willing to accept across the whole sample typically 0.05 (5%), q is the proportion of false positives (false â€˜discoveriesâ€™) that we are willing to accept within the significant results. In this example we will set q to 0.05 (5%) as well.

Here we are going to apply the Benjamini-Hochberg (BH) method to the data from the Fishers LSD test in the previous practical in section B2.1

Firstly, take the P values for each comparison of pairs and put them in ascending numerical order. Then assign a rank number in that order (smallest P value is rank 1, next smallest rank 2 and so on).

Group A |
Group B |
P |
Rank |

Normal | Obese | <0.001 | 1 |

Normal | Overweight | 0.001 | 2 |

Underweight | Obese | 0.013 | 3 |

Overweight | Obese | 0.056 | 4 |

Underweight | Overweight | 0.060 | 5 |

Underweight | Normal | 0.246 | 6 |

Calculate the BH critical value for each P value, using the formula q(i/m), where:

i = the individual p-valueâ€™s rank,

m = total number of tests,

q= the false discovery rate you have selected (0.05)

Group A |
Group B |
P |
Rank |
BH_{crit} |
Significant |

Normal | Obese | <0.001 | 1 | 0.008 | Yes |

Normal | Overweight | 0.001 | 2 | 0.016 | Yes |

Underweight | Obese | 0.013 | 3 | 0.025 | Yes |

Overweight | Obese | 0.056 | 4 | 0.033 | No |

Underweight | Overweight | 0.060 | 5 | 0.042 | No |

Underweight | Normal | 0.246 | 6 | 0.050 | No |

P values which are __lower__ than our BH critical values are considered true â€˜discoveriesâ€™. The first P value which is __higher__ than the BH critical value and __all significant P values below__ that (below in terms of the table, higher rank numbers) would be considered false â€˜discoveriesâ€™. P values of â‰¥0.05 are not treated any differently to normal.

From this we can conclude that all three of our statistically significant differences from out pairwise comparisons are in true â€˜discoveriesâ€™, and none of them should be discounted.

With small numbers of comparisons like this it is easy to use this method by hand, however where the FDR approach is most useful is when we are making very large numbers (hundreds) of comparisons.

—-

To compute this in R use the code

BH(u, alpha = 0.05)

where u is a vector containing all of the P values, and alpha is in fact your specified value for q

—-

To compute this is Stata you need to download the package smileplot which contains the programme multploc. This will allow you to perform the BH test. More details can be seen on this here- https://www.rogernewsonresources.org.uk/papers/multproc.pdf

—-

In SPSS there is a function to do this test within one of the extension bundles, but you can create a variable which contains all of your P values and then conduct a calculation for BH critical values using the â€˜compute variableâ€™ function (see A1.6) then make a visual assessment.

—-

There are also online FDR calculator you can use like this one https://tools.carbocation.com/FDR.

Try analysing the data from our example with at least one other method to check your results.

You can download a copy of the slides here:Â B2.2b Correcting for Multiple Comparisons

## B2.2b PRACTICAL: R

In Practical B2.1, we ran the Fisherâ€™s LSD test to compare systolic blood pressure (SBP) between each possible pairing of groups in the BMI group categorical variable. Now we know a little be more about post hoc tests and correcting for multiple comparisons, we are going to go back and conduct the Bonferroni post hoc and Tukeyâ€™s HSD post hoc on the same data.Â Â Â

Tukey’s test in R

The function is â€˜TukeyHSDâ€™ (which comes loaded in R already so you do not need to install any packages). You run this function after you fit the ANOVA as you did in B2.1:Â

> model1<- aov(sbp~bmi_fact, data=white.data) Â > summary(model1)Â [output omitted]Â > TukeyHSD(model1, conf.level = .95)Â Â Tukey multiple comparisons of meansÂ Â Â Â 95% family-wise confidence levelÂ Â Fit: aov(formula = sbp ~ bmi_fact, data = white.data)Â Â $bmi_factÂ Â Â Â Â Â Â Â diffÂ Â Â Â Â Â Â lwrÂ Â Â Â Â Â uprÂ Â Â Â p adjÂ 2-1 2.909514 -3.5381290Â 9.357157 0.6523423Â 3-1 4.706123 -1.7291986 11.141444 0.2370134Â 4-1 6.579362 -0.1897670 13.348490 0.0603475Â 3-2 1.796609Â 0.3476829Â 3.245534 0.0079012Â 4-2 3.669847Â 1.1189404Â 6.220755 0.0012615Â 4-3 1.873239 -0.6463616Â 4.392839 0.2235822Â

Bonferroni test in RÂ

To perform a Bonferroni correction, you run the post estimation function â€˜pairwise.t.test(x, g, p.adjust.method =’bonferroni’)â€™. Here â€˜xâ€™ is your response variable, â€˜gâ€™ is the grouping variable, and for p.adjust.method you specify â€˜bonferroniâ€™.Â

The output is:Â

> model1<- aov(sbp~bmi_fact, data=white.data) Â > summary(model1)Â [output omitted]Â pairwise.t.test(white.data$sbp, white.data$bmi_grp4, p.adjust.method ='bonferroni')Â Â Pairwise comparisons using t tests with pooled SD Â Â data:Â white.data$sbp and white.data$bmi_grp4 1Â Â Â Â Â 2Â Â Â Â Â 3Â Â Â Â Â

2 1.0000 -Â Â Â Â Â -Â Â Â Â Â

3 0.3615 0.0087 -Â Â Â Â Â

4 0.0752 0.0013 0.3366 P value adjustment method: bonferroniÂ

**Consider the different post hoc tests and the results for each comparison in them. Is one method producing higher or lower p values than the others? Do any previously significant findings become non-significant after correction for multiple comparisons?**

**Answer**

The table below shows the outcome for each of the possible pairs, for each of the three different post hoc tests. These have been ordered from smallest to largest p value for ease of comparison.Â Â

Â Group AÂ |
Â Group BÂ |
P valueÂ |
||

Fisherâ€™s LSDÂ |
Tukeyâ€™sÂ HSDÂ |
BonferroniÂ |
||

NormalÂ | ObeseÂ | <0.001*Â | 0.001*Â | 0.001*Â |

NormalÂ | OverweightÂ | 0.001*Â | 0.008*Â | 0.009*Â |

UnderweightÂ | ObeseÂ | 0.013*Â | 0.060Â | 0.075Â |

OverweightÂ | ObeseÂ | 0.056Â | 0.224Â | 0.337Â |

UnderweightÂ | OverweightÂ | 0.060Â | 0.237Â | 0.361Â |

UnderweightÂ | NormalÂ | 0.246Â | 0.652Â | 1.000Â |

*= P<0.05- Reject H0

You should notice that the p-vales are lowest for each comparison on the LSD test, and highest in the Bonferroni. Once we apply a correction for multiple comparisons in this way the significant difference in SBP between underweight and obese groups disappears and we fail to reject the null hypothesis for this pairing.

## B2.2b PRACTICAL: Stata

In Practical B2.1, we ran the Fisherâ€™s LSD test to compare systolic blood pressure (SBP) between each possible pairing of groups in the BMI group categorical variable. Now we know a little be more about post hoc tests and correcting for multiple comparisons, we are going to go back and conduct the Bonferroni post hoc and Tukeyâ€™s HSD post hoc on the same data.Â Â Â

The post-estimation command â€˜pwcompareâ€™Â with the â€˜mcompare(method)â€™ option specifies the method for computing p-values and confidence intervals that account for multiple comparisons.Â Â

In the Fisherâ€™s LSD example we used â€˜mcompare(noadjust)â€™, meaning there is no adjustment for multiple comparisons.Â Â

To run the same test with Bonferroni post hoc replace this with â€˜mcompare(bonferroni)â€™.Â

To run the Tukeyâ€™s post hoc replace this with â€˜mcompare(tukey)â€™Â Â

See the output here:Â

quietly: anova sbp bmi_grp4 pwcompare bmi_grp4, mcompare(bonferroni) effectsÂ

`pwcompare bmi_grp4, mcompare(tukey) effectsÂ `

**Consider the different post hoc tests and the results for each comparison in them. Is one method producing higher or lower p values than the others? Do any previously significant findings become non-significant after correction for multiple comparisons?**

**Answer**

The table below shows the outcome for each of the possible pairs, for each of the three different post hoc tests. These have been ordered from smallest to largest p value for ease of comparison.Â Â

Â Group AÂ |
Â Group BÂ |
P valueÂ |
||

Fisherâ€™s LSDÂ |
Tukeyâ€™sÂ HSDÂ |
BonferroniÂ |
||

NormalÂ | ObeseÂ | <0.001*Â | 0.001*Â | 0.001*Â |

NormalÂ | OverweightÂ | 0.001*Â | 0.008*Â | 0.009*Â |

UnderweightÂ | ObeseÂ | 0.013*Â | 0.060Â | 0.075Â |

OverweightÂ | ObeseÂ | 0.056Â | 0.224Â | 0.337Â |

UnderweightÂ | OverweightÂ | 0.060Â | 0.237Â | 0.361Â |

UnderweightÂ | NormalÂ | 0.246Â | 0.652Â | 1.000Â |

*= P<0.05- Reject H0

You should notice that the p-vales are lowest for each comparison on the LSD test, and highest in the Bonferroni. Once we apply a correction for multiple comparisons in this way the significant difference in SBP between underweight and obese groups disappears and we fail to reject the null hypothesis for this pairing.

## B2.2b PRACTICAL: SPSS

In Practical B2.1, we ran the Fisherâ€™s LSD test to compare systolic blood pressure (SBP) between each possible pairing of groups in the BMI group categorical variable. Now we know a little be more about post hoc tests and correcting for multiple comparisons, we are going to go back and conduct the Bonferroni post hoc and Tukeyâ€™s HSD post hoc on the same data.Â Â Â

Run the ANOVA in exactly the same way as before, but when you reach the screen where you tick the box next to your choice of post hoc tests, select â€˜Bonferroniâ€™ and â€˜Tukeyâ€™.

**Consider the different post hoc tests and the results for each comparison in them. Is one method producing higher or lower p values than the others? Do any previously significant findings become non-significant after correction for multiple comparisons?**

**Answer**

The table below shows the outcome for each of the possible pairs, for each of the three different post hoc tests. These have been ordered from smallest to largest p value for ease of comparison.Â Â

Â Group AÂ |
Â Group BÂ |
P valueÂ |
||

Fisherâ€™s LSDÂ |
Tukeyâ€™sÂ HSDÂ |
BonferroniÂ |
||

NormalÂ | ObeseÂ | <0.001*Â | 0.001*Â | 0.001*Â |

NormalÂ | OverweightÂ | 0.001*Â | 0.008*Â | 0.009*Â |

UnderweightÂ | ObeseÂ | 0.013*Â | 0.060Â | 0.075Â |

OverweightÂ | ObeseÂ | 0.056Â | 0.224Â | 0.337Â |

UnderweightÂ | OverweightÂ | 0.060Â | 0.237Â | 0.361Â |

UnderweightÂ | NormalÂ | 0.246Â | 0.652Â | 1.000Â |

*= P<0.05- Reject H0

You should notice that the p-vales are lowest for each comparison on the LSD test, and highest in the Bonferroni. Once we apply a correction for multiple comparisons in this way the significant difference in SBP between underweight and obese groups disappears and we fail to reject the null hypothesis for this pairing.