While calculating the Tukey statistic, we use the MSE calculated in the one-way ANOVA test.
Tukey’s Test For Post-Hoc Analysis Using Python
We can use the following Python code to calculate the statistics in Tukey’s test for post-hoc analysis.
import numpy
import pandas
from statsmodels.stats.multicomp import pairwise_tukeyhsd
# Perform Tukey's test
df = pandas.DataFrame({'marks': [75, 50, 67, 59, 73, 82, 63, 69, 57, 81, 80, 92, 69, 69, 82, 57, 59, 82, 76, 66,
84, 92, 81, 63, 75, 80, 68, 86, 86, 77, 70, 69, 84, 88, 66, 67, 85, 60, 69, 64,
73, 73, 69, 71, 85, 86, 75, 77, 90, 70, 95, 84, 88, 85, 90, 91, 85, 74, 91, 65],
'group': numpy.repeat(['I', 'II', 'III'], repeats=20)})
result = pairwise_tukeyhsd(endog=df['marks'], groups=df['group'], alpha=0.05)
print(result)
Here, we are using the pairwise_tukeyhsd() function to calculate the test statistics in the Tukey’s test for post-hoc analysis. The output of the above program will be like the following: …








































0 Comments