## 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
- Apply extensions to the basic ANOVA test and interpret their results
- Explain when and how to use repeated measures statistics

You can download a copy of the slides here: B2.1 ANOVA Revisited- Post Hoc Testing

## B2.1 PRACTICAL: R

In the last module we looked at linear regression to analyse the effect of different explanatory variables on the SBP of the participants.

We are going to revisit this here and look at it through the lens of the ANOVA.

Letâ€™s look at the association of mean SBP across BMI groups again. But now we want to use the ANOVA post-estimation options to compute multiple comparisons with Fisherâ€™s least-significant difference (LSD) test, which does not adjust the confidence intervals or p-values.

We can use the â€˜LSD.test()â€™ function of the â€˜agricolaeâ€™ package to perform this test in R.

#define group (factor) variable & fit one-way ANOVA

white.data<-Whitehall_fossa

white.data$bmi_fact<-factor(white.data$bmi_grp4)

model1<- aov(sbp~bmi_fact, data=white.data)Â summary(model1)

Â Â Â Â Â Â Â Â Â Â Df Â Sum Sq Mean Sq F value Â Pr(>F)

bmi_fact Â Â Â 3 Â Â 6451 Â 2150.4 Â 7.024 0.000104 ***

Residuals Â 4297 1315528 Â 306.2

—

Signif. codes: Â 0 â€˜***â€™ 0.001 â€˜**â€™ 0.01 â€˜*â€™ 0.05 â€˜.â€™ 0.1 â€˜ â€™ 1

26 observations deleted due to missingness

#perform Fisherâ€™s LSD

install.packages(“agricolae”)

library(agricolae)

print(LSD.test(model1, “bmi_fact”))Â

$statisticsMSerrorÂ Â DfÂ Â Â MeanÂ Â Â Â Â CV306.1504 4297 130.727 13.3845$parameters
test p.ajustedÂ Â name.t ntr alpha Fisher-LSDÂ Â Â Â Â none bmi_factÂ Â 4Â 0.05 $means sbpÂ Â Â Â Â stdÂ Â Â rÂ Â Â Â Â LCLÂ Â Â Â Â UCL Min Max Q25Â Â Q50Â Â Â Q75 1 126.6600 18.47294Â Â 50 121.8088 131.5112Â 86 176 115 125.5 136.75 2 129.5695 17.49645 1791 128.7589 130.3801Â 87 230 118 128.0 139.00 3 131.3661 17.59025 2084 130.6147 132.1176Â 88 218 119 130.0 142.00 4 133.2394 16.83856Â 376 131.4703 135.0084Â 94 190 122 132.0 143.00 $comparison NULL $groups sbp groups 4 133.2394Â Â Â Â Â a 3 131.3661Â Â Â Â Â a 2 129.5695Â Â Â Â Â b 1 126.6600Â Â Â Â Â b attr(,”class”) [1] “group” |

To interpret this output we look at the section headed â€˜$groupsâ€™. The groups that have different characters listed beside them (i.e. â€˜aâ€™ or â€˜bâ€™) are significantly different.

*Question B2.1:*Review your output. What do you notice? What can you conclude about the data from these tests? Compare this to your output from the linear regression on the same data.

**Answer**

__Answer B2.1__

The output of the main ANOVA gives the same values as the previous tests on this relationship (to be expected!). The post hoc testing, in the table titled â€˜$groupsâ€™, shows the same relationships between groups as seen in the comparisons to reference categories shown as part of the linear regression on these data. Do check this for yourself by comparing to your own results from exercise B1.3.

The advantage of this method is that all of the comparisons are shown in one table, so you can inspect any pairing you wish.

In this output, we can see that :

- Group 4 and group 2 have significantly different mean SBP, since group 4 has a value of â€˜aâ€™ and group 2 has a value of â€˜bâ€™.
- Group 4 and group 1 have significantly different mean SBP, since group 4 has a value of â€˜aâ€™ and group 1 has a value of â€˜bâ€™.
- Group 4 and group 3 do NOT have significant different mean SBP, since they both have a value of â€˜aâ€™.

## B2.1 PRACTICAL: Stata

In the last module we looked at linear regression to analyse the effect of different explanatory variables on the SBP of the participants.

We are going to revisit this here and look at it through the lens of the ANOVA.

Letâ€™s look at the association of mean SBP across BMI groups again. But now we want to use the ANOVA post-estimation options to compute multiple comparisons with Fisherâ€™s least-significant difference (LSD) , which does not adjust the confidence intervals or p-values.

We can use the post-estimation command â€˜pwcompareâ€™ to run this test. In Stata, the default mcompare(noadjust) corresponds to Fisherâ€™s protected LSD.

anova sbp bmi_grp4

[output omitted]

pwcompare bmi_grp4, mcompare(noadjust) effects

__Question B2.1:__**Review your output. What do you notice? What can you conclude about the data from these tests? Compare this to your output from the linear regression on the same data.**

**Answer**

The output of the main ANOVA gives the same values as the previous tests on this relationship (to be expected!). The post hoc testing, in the table titled â€˜Pairwise comparisonsâ€™, shows the same relationships between groups as seen in the comparisons to reference categories shown as part of the linear regression on these data. Do check this for yourself by comparing to your own results from exercise B1.3.

The advantage of this method is that all of the comparisons are shown in one table, so you can inspect any pairing you wish.

## B2.1 PRACTICAL: SPSS

In the last module we looked at linear regression to analyse the effect of different explanatory variables on the SBP of the participants.

We are going to revisit this here and look at it through the lens of the ANOVA.

Select

Analyze >> Compare Means and Proportions >> One-Way ANOVA

Move SBP into the Dependant List and BMI grouping (bmi_grp4) into the Factor box as before.

Now in and additional step, click on the post hoc button on the right-hand side. You will see a new box open up with lots of options for post hoc tests. We are going to select the very first option in the â€˜Equal Variances Assumedâ€™ section â€˜LSDâ€™ which stands for Least Significant Difference.

Press continue and then OK to run the test.

**Review your output. What do you notice? What can you conclude about the data from these tests? Compare this to your output from the linear regression on the same data. **

**Answer**

The output of the main ANOVA gives the same values as the previous tests on this relationship (to be expected!). The post hoc testing, in the table helpfully titled â€˜Multiple Comparisonsâ€™, shows the same relationships between groups as seen in the comparisons to reference categories shown as part of the linear regression on these data. Do check this for yourself by comparing to your own results from exercise B1.3.

The advantage of this method is that all of the comparisons are shown in one table, so you can inspect any pairing you wish.

When I click on link for getting copy of the presentation: B2.1 ANOVA Revisited- Post Hoc Testing

it goes to: https://login.canvas.ox.ac.uk page. Could you please add the presentation here