UK-based online statistics and data analysis support for USA, UK, and international clients. No exams, no impersonation, no fabricated data.
Post Hoc Tests

Tukey Kramer Test: Formula, Interpretation, SPSS, Python, R and Excel Guide

Post Hoc Test After ANOVA, Unequal Sample Sizes and Family-Wise Adjustment Tukey Kramer Test: Formula, Interpretation, SPSS, Python, R and Excel Guide Tukey Kramer Test is...

Statistics guide Ethical learning support SPSS/R/Python/Excel friendly
Tukey Kramer Test: Formula, Interpretation, SPSS, Python, R and Excel Guide

Post Hoc Test After ANOVA, Unequal Sample Sizes and Family-Wise Adjustment

Tukey Kramer Test: Formula, Interpretation, SPSS, Python, R and Excel Guide

Tukey Kramer Test is a post hoc pairwise comparison method used after a significant one-way ANOVA when you need to compare all group means while controlling the family-wise error rate. It is especially useful when group sample sizes are unequal. This guide explains Tukey-Kramer post hoc testing with ANOVA evidence, unequal-n standard errors, studentized range q statistics, adjusted p-values, simultaneous confidence intervals, homogeneous subset letters, SPSS output, Python charts, R validation, Excel workflow and reporting language.

Advertisement
Google AdSense top placement reserved here

Quick Answer: Tukey Kramer Test Result

The worked example compares G3 final grade across four studytime groups. The one-way ANOVA was statistically significant, F(3, 645) = 15.876, p = 5.705728e-10, meaning at least one studytime group mean differed from another. The effect size was modest, with eta squared = 0.0688 and omega squared = 0.0643. Because the omnibus ANOVA was significant, the Tukey Kramer Test was used to identify which specific group pairs differed while controlling the family-wise error rate.

The Tukey-Kramer procedure used a pooled within-group error variance of MSE = 9.7646, df error = 645, four groups, and a family-wide studentized range critical value of q critical = 3.6426. The group sizes were clearly unequal: group 1 had n = 212, group 2 had n = 305, group 3 had n = 97, and group 4 had n = 35. This unequal sample-size structure is exactly why the Tukey-Kramer adjustment is preferred over a simple equal-n Tukey HSD shortcut.

Target variableG3
Group variablestudytime
Total sample size649
Number of groups4

ANOVA resultp < .001
Pooled MSE9.7646
q critical3.6426
Significant pairs4 of 6

Final interpretation: The Tukey Kramer Test found significant differences for studytime 1 vs 2, 1 vs 4, 1 vs 3, and 2 vs 3. The comparisons 2 vs 4 and 4 vs 3 were not statistically significant after family-wise adjustment. In practical terms, the lowest studytime group had the lowest mean G3 score, while studytime groups 3 and 4 formed the highest homogeneous subset.

Important decision point: The median-centered Levene / Brown-Forsythe context test gave p = 0.3804, so serious variance heterogeneity was not indicated in this worked example. If variance heterogeneity were serious, a method such as Games-Howell or Tamhane’s T2 would be safer than Tukey-Kramer.

Table of Contents

  1. What Is the Tukey Kramer Test?
  2. When to Use Tukey Kramer Test
  3. Tukey Kramer Test Formula
  4. Hypotheses and Decision Rule
  5. Dataset and Variables Used
  6. ANOVA and Assumption Context
  7. Tukey Kramer Pairwise Results
  8. Python Chart-by-Chart Interpretation
  9. R Chart-by-Chart Validation
  10. SPSS, R, Python and Excel Workflows
  11. Code Blocks for Tukey Kramer Test
  12. APA Reporting Wording
  13. Common Mistakes
  14. Downloads and Resources
  15. Related Guides
  16. FAQs

What Is the Tukey Kramer Test?

The Tukey Kramer Test is a multiple comparison procedure used after ANOVA to compare all possible pairs of group means. It answers the practical question that ANOVA alone does not answer: after finding that the group means are not all equal, which specific pairs are different? The method uses the studentized range distribution and adjusts the comparison standard error when the sample sizes are unequal.

The test is closely related to Tukey’s HSD. In many software packages, the Tukey-Kramer procedure is treated as the unequal-sample-size extension of Tukey HSD. When all group sample sizes are equal, the Tukey-Kramer and Tukey HSD logic become very similar. When sample sizes differ, Tukey-Kramer calculates each pairwise standard error using both group sample sizes, which prevents the analyst from applying one misleading equal-n threshold to every comparison.

In this worked example, the group sizes are strongly unequal, from n = 35 to n = 305. This creates different uncertainty levels for different group pairs. The comparison between group 4 and group 3 has the largest Tukey-Kramer standard error because group 4 has only 35 observations, while the comparison between group 1 and group 2 has a smaller standard error because both groups are large.

Simple definition: Tukey Kramer Test is a post hoc ANOVA method that compares every pair of means, controls family-wise Type I error, and adjusts standard errors for unequal group sample sizes.

When to Use Tukey Kramer Test

Use the Tukey Kramer Test when you have a significant one-way ANOVA and you want to compare all possible pairs of group means. It is most appropriate when the dependent variable is continuous, the grouping variable has three or more independent groups, the pairwise comparisons are all pairwise rather than a small set of planned contrasts, and the equal-variance assumption is acceptable enough to use the pooled ANOVA error variance.

The phrase when to use Tukey Kramer test often appears in student searches because many learners are unsure whether the method is only for unequal sample sizes. The clean answer is that Tukey-Kramer is appropriate for all-pair post hoc comparisons after ANOVA, and it is especially useful when the group sample sizes are unequal. If sample sizes are equal, many software outputs simply call the method Tukey HSD. If sample sizes are unequal, Tukey-Kramer is the safer name because the standard error changes for each pair.

QuestionUse Tukey Kramer?Reason
ANOVA is significant and all group pairs must be comparedYesThe method controls family-wise error across all pairwise comparisons.
Group sample sizes are unequalYesThe pairwise standard error uses both group sample sizes.
Only two groups are being comparedNoA t test or two-group ANOVA is enough because there is only one comparison.
Variances are seriously unequalUsually noGames-Howell or Tamhane’s T2 is usually safer when heterogeneity is serious.
Only a few planned comparisons were specified before analysisNot alwaysPlanned contrasts may be more powerful and more focused.

Before choosing Tukey-Kramer, check the broader ANOVA context. Helpful supporting guides include one-way ANOVA, ANOVA assumptions, Levene test, Brown-Forsythe test, effect size, and p-value interpretation.

Tukey Kramer Test Formula

The Tukey Kramer Test compares the absolute difference between two group means with a standard error that uses the pooled ANOVA mean square error and the two sample sizes in the pair. The test statistic is a studentized range statistic, usually written as q.

q = |Mi – Mj| / √[(MSE / 2) × (1/ni + 1/nj)]

The denominator is the Tukey-Kramer pairwise standard error. Unlike a simple equal-n Tukey HSD calculation, this standard error changes from one pair to another when group sample sizes are unequal. Pairs involving a small group usually have larger standard errors, which makes it harder for those comparisons to become significant.

SymbolMeaningValue or Role in This Example
qStudentized range test statisticCompared with q critical = 3.6426.
Mi, MjTwo group meansExample: studytime 1 mean = 10.8443 and studytime 3 mean = 13.2268.
MSEPooled within-group mean square error9.7646 from the one-way ANOVA error term.
ni, njSample sizes for the two groupsUnequal group sizes from 35 to 305.
kNumber of groups in the family4 groups.
df errorWithin-group error degrees of freedom645.

Decision formula: a pair is significant when its observed q statistic is larger than the family-wide q critical value, or equivalently when the Tukey-Kramer adjusted p-value is below alpha.

Hypotheses and Decision Rule for Tukey Kramer Test

The Tukey-Kramer method tests each pair of means separately while controlling the family-wise error rate across the full set of pairwise comparisons. In this example, there are four groups, so there are six possible pairwise comparisons.

Comparison-Level StatementHypothesisDecision Rule
Null hypothesis for a pairH0: μi = μjThe two group means are not significantly different.
Alternative hypothesis for a pairH1: μi ≠ μjThe two group means are significantly different.
q statistic ruleq observed > q criticalReject the pairwise null hypothesis.
Adjusted p-value rulep adjusted < .05Reject the pairwise null hypothesis at family-wise alpha .05.
Confidence interval ruleSimultaneous CI excludes zeroConclude a significant pairwise mean difference.

Decision in this example: Four of six comparisons were significant after Tukey-Kramer adjustment. The pairs 1 vs 2, 1 vs 4, 1 vs 3 and 2 vs 3 were significant. The pairs 2 vs 4 and 4 vs 3 were not significant.

Dataset and Variables Used

The worked example uses G3 final grade as the continuous outcome and studytime as the grouping variable. The sample contains 649 observations. The four studytime groups are independent categories, and their sample sizes are unequal, which makes the example useful for demonstrating the Tukey-Kramer method.

VariableRoleInterpretation in This Guide
G3Dependent variableFinal grade score compared across studytime groups.
studytimeGrouping variableFour-level independent group variable used for ANOVA and post hoc comparisons.
Group meanDescriptive statisticAverage G3 score in each studytime level.
Group nSample-size inputUsed directly in Tukey-Kramer unequal-n standard errors.
Pooled MSEANOVA error termUsed as the common within-group variance estimate for pairwise comparisons.

For readers who need background before running post hoc tests, start with descriptive statistics, mean, median and mode, standard deviation, confidence interval, and one-way ANOVA.

Advertisement
Google AdSense middle placement reserved here

ANOVA and Assumption Context Before Tukey Kramer Test

The Tukey-Kramer procedure should be interpreted after the omnibus ANOVA result. In this example, the one-way ANOVA showed a statistically significant difference among the four studytime means. The ANOVA p-value was very small, so the global equal-means hypothesis was rejected. The post hoc test then identified where the differences were located.

ANOVA ItemValueInterpretation
Target variableG3Final grade score.
Group variablestudytimeFour independent studytime groups.
Total n649Valid observations included in the analysis.
Number of groups4Creates six possible pairwise comparisons.
SS between465.0778Variation explained by studytime group differences.
SS within error6298.1887Within-group residual variation.
MS between155.0259Between-group mean square.
Pooled MSE9.7646Within-group error variance used in Tukey-Kramer standard errors.
F statistic15.8763Omnibus ANOVA evidence against equal means.
p-value5.705728e-10Reject equal means at alpha .05.
Eta squared0.0688About 6.9% of G3 variation is associated with studytime group membership.
Omega squared0.0643Bias-adjusted effect size estimate.

Equal-Variance Context

The Levene / Brown-Forsythe context test used a median-centered approach and returned statistic = 1.0263 with p = 0.3804. This does not indicate serious variance heterogeneity at the .05 level. That matters because Tukey-Kramer uses the pooled ANOVA MSE. When that pooled variance assumption is badly violated, equal-variance post hoc methods can become less reliable.

Context CheckValueInterpretation
Median-centered Levene / Brown-Forsythe statistic1.0263Variance check statistic.
p-value0.3804No strong evidence of unequal variances in this example.
Largest group n305Studytime group 2 has the largest sample size.
Smallest group n35Studytime group 4 has the smallest sample size.
Largest-to-smallest n ratio8.7143The sample sizes are clearly unequal, supporting Tukey-Kramer rather than equal-n HSD shortcuts.

Tukey Kramer Pairwise Results

The group summary shows a clear upward pattern from studytime group 1 to studytime group 3. Studytime group 1 had the lowest mean G3 score at 10.8443. Studytime group 2 had a higher mean of 12.0918. Studytime group 3 had the highest mean at 13.2268, while group 4 had a very similar mean of 13.0571 but a much smaller sample size.

studytime GroupnMean G3SDSE95% CI Low95% CI High
121210.84433.21860.221110.411111.2776
230512.09183.24310.185711.727812.4558
39713.22682.50210.254112.728913.7247
43513.05713.03840.513612.050514.0638

The pairwise comparison table confirms which differences remained statistically significant after family-wise adjustment. The largest mean difference was between studytime group 1 and group 3, with a mean difference of 2.3825, q = 8.7961, and adjusted p = 5.367514e-09. This comparison clearly exceeded the family-wide q critical value of 3.6426.

ComparisonMean DifferenceTukey-Kramer SEq StatisticAdjusted p-valueSimultaneous CIDecision
1 vs 21.24750.19766.31380.0000559[0.5278, 1.9672]Significant
1 vs 42.21280.40315.48890.0006612[0.7443, 3.6813]Significant
1 vs 32.38250.27098.79610.00000000537[1.3958, 3.3691]Significant
2 vs 40.96530.39432.44800.3084[-0.4711, 2.4018]Not significant
2 vs 31.13500.25764.40660.0103[0.1968, 2.0732]Significant
4 vs 30.16970.43570.38940.9927[-1.4174, 1.7567]Not significant

Homogeneous subset interpretation: group 3 and group 4 share subset letter A, so they are not significantly different from each other. Group 2 is in subset B, and group 1 is in subset C. Groups with different letters are significantly different at the family-wise alpha level.

Python Chart-by-Chart Interpretation

The Python charts below show the complete Tukey-Kramer workflow: group means and sample sizes, unequal-n standard errors, q statistics, adjusted p-values, simultaneous confidence intervals, decision matrix, homogeneous subset letters and a method report card. The first set of images is useful for explaining the result visually in a report or classroom setting.

Python Chart 1: Tukey-Kramer Group Means and Sample Sizes

Tukey Kramer Test group means and sample sizes for studytime groups
Group means for G3 by studytime with descriptive 95% confidence intervals and unequal sample-size labels.

The first chart shows the four studytime group means. Group 1 has the lowest mean G3 score, 10.84, with n = 212. Group 2 is higher at 12.09, group 3 is highest at 13.23, and group 4 is close to group 3 at 13.06. The visual pattern already suggests that the lowest studytime group is separated from the higher studytime groups.

The sample-size labels are important because Tukey-Kramer does not treat every comparison as equally precise. Group 4 has only 35 observations, so its confidence interval is wider. This is why unequal-n adjustment matters: even if a mean looks high, a smaller group carries more uncertainty in pairwise testing.

Python Chart 2: Unequal-n Standard Errors

Tukey Kramer unequal sample size standard errors for each pairwise comparison
Tukey-Kramer standard errors for all pairwise comparisons, showing how unequal group sizes change uncertainty.

The unequal-n standard error chart shows why the Tukey-Kramer method is more appropriate than an equal-n shortcut here. The largest standard error belongs to 4 vs 3, because group 4 is the smallest group and group 3 is also smaller than group 2. The comparison 1 vs 2 has the smallest standard error because both groups are relatively large.

This chart explains why a mean difference cannot be judged by size alone. A pair with a moderate difference and a small standard error can become significant, while a pair with a similar difference and a large standard error may fail to reach significance. Tukey-Kramer builds this unequal precision into every comparison.

Python Chart 3: q Statistics vs Family-Wide Critical Value

Tukey Kramer q statistics compared with family-wide q critical value
Observed q statistics compared with the one family-wide Tukey-Kramer critical value.

The red dashed line marks the family-wide q critical value of about 3.643. Any observed q statistic extending beyond this line is significant. The chart shows that 1 vs 3, 1 vs 2, 1 vs 4, and 2 vs 3 exceed the critical value, while 2 vs 4 and 4 vs 3 do not.

The strongest result is 1 vs 3, with q near 8.80. The weakest result is 4 vs 3, with q near 0.39, which is far below the critical value. This supports the conclusion that groups 3 and 4 are statistically similar in mean G3 score.

Python Chart 4: Adjusted p-value Ranking

Tukey Kramer adjusted p-value ranking for all pairwise comparisons
Adjusted p-values controlling the family-wise error rate across all Tukey-Kramer pairwise comparisons.

The adjusted p-value chart tells the same story from the p-value perspective. The vertical red line marks alpha = 0.05. Comparisons with bars to the left of this line are significant after family-wise adjustment. The comparisons involving group 1 against groups 2, 3 and 4 are significant, and the comparison 2 vs 3 is also significant.

The chart also makes the two non-significant comparisons clear. The adjusted p-value for 2 vs 4 is about 0.308, and the adjusted p-value for 4 vs 3 is about 0.993. These values are too large to reject the pairwise null hypothesis after controlling family-wise error.

Python Chart 5: Simultaneous Confidence Intervals

Tukey Kramer simultaneous confidence intervals for pairwise mean differences
Simultaneous Tukey-Kramer confidence intervals for all pairwise mean differences.

The simultaneous confidence interval chart shows pairwise mean differences with intervals adjusted for multiple comparisons. Intervals that do not cross zero indicate significant differences. The intervals for 1 vs 2, 1 vs 4, 1 vs 3, and 2 vs 3 stay entirely above zero, confirming those four significant results.

The intervals for 2 vs 4 and 4 vs 3 cross zero. That means the adjusted confidence interval allows a difference of zero, so those pairs are not statistically significant. This chart is often easier for readers than a p-value table because it shows both the direction and the uncertainty of each mean difference.

Python Chart 6: Pairwise Decision Matrix

Tukey Kramer pairwise decision matrix with significant and non-significant comparisons
Decision matrix marking significant and non-significant Tukey-Kramer pairwise results.

The decision matrix condenses the full post hoc result into a compact grid. The green cells mark significant pairwise differences and the red cells mark non-significant comparisons. Group 1 differs significantly from every other group, which confirms that the lowest studytime group is clearly separated from the others in mean G3 score.

The matrix also highlights the important upper-group pattern. Group 3 and group 4 are not significantly different, and group 2 and group 4 are also not significantly different after Tukey-Kramer adjustment. However, group 2 and group 3 are significantly different, showing that group 3 still stands above group 2 despite the family-wise correction.

Python Chart 7: Homogeneous Subset Letters

Tukey Kramer homogeneous subset letters for studytime groups
Homogeneous subset letters showing which studytime groups are not significantly different after Tukey-Kramer adjustment.

The homogeneous subset chart provides a report-friendly summary. Groups sharing a letter are not significantly different. Group 3 and group 4 both receive letter A, meaning they form the highest non-different subset. Group 2 receives letter B, and group 1 receives letter C.

This letter display is useful when there are many comparisons because it avoids making readers inspect every pair one by one. In this example, the final pattern is easy to explain: group 1 is the lowest subset, group 2 is the middle subset, and groups 3 and 4 are the highest subset.

Python Chart 8: Tukey-Kramer Method Report Card

Tukey Kramer method report card summarizing ANOVA p value q critical significant pairs n ratio and pooled MSE
Report card summarizing ANOVA evidence, q critical value, number of significant pairs, sample-size imbalance and pooled MSE.

The method report card summarizes the key evidence needed for a complete Tukey-Kramer report. The ANOVA p-value is essentially zero at the displayed precision, the family-wide q critical value is 3.643, and 4 of 6 pairwise comparisons are significant. It also reports the sample-size imbalance and pooled MSE.

The n ratio of about 8.71 confirms why the Tukey-Kramer unequal-n version is appropriate. The pooled MSE of about 9.765 confirms the within-group error variance used to calculate every pairwise standard error. This chart is a good final dashboard for checking that the post hoc decision is supported by the ANOVA framework.

R Chart-by-Chart Validation

The R validation charts reproduce the same Tukey-Kramer logic with a separate workflow. Agreement between Python, R and SPSS strengthens confidence that the result is not a software artifact. The R charts below use the uploaded validation image set with the -1 filenames.

R Chart 1: Tukey-Kramer Group Means and Sample Sizes

R Tukey Kramer group means and sample sizes validation chart
R validation chart showing group means, confidence intervals and unequal sample sizes.

The R group mean chart validates the same descriptive pattern as Python. Studytime group 1 remains the lowest mean group, group 2 is higher, and groups 3 and 4 are the highest groups. The unequal sample sizes are again visible in the labels and the confidence interval widths.

This validation is important because post hoc interpretation begins with the descriptive pattern. The R chart confirms that the strongest practical separation is between the lowest studytime group and the higher studytime groups.

R Chart 2: Unequal-n Standard Errors

R Tukey Kramer unequal sample size standard errors validation chart
R validation chart showing pair-specific Tukey-Kramer standard errors.

The R standard error chart confirms that the pairwise standard errors are not identical. Pairs involving the smallest group have larger uncertainty, while the largest groups produce more precise comparisons. This validates the unequal-n logic used in the test.

The chart also helps prevent a common reporting mistake. A Tukey-Kramer result should not be explained as if one identical standard error applied to every pair when the group sizes are unequal.

R Chart 3: q Statistics vs Family-Wide Critical Value

R Tukey Kramer q statistics versus family critical value validation chart
R validation chart comparing observed q statistics with the family-wide q critical value.

The R q statistic chart validates the same four significant comparisons. The bars for 1 vs 3, 1 vs 2, 1 vs 4 and 2 vs 3 exceed the family-wide q critical value. The bars for 2 vs 4 and 4 vs 3 stay below the threshold.

This chart is the direct visual decision rule for the Tukey-Kramer test. It confirms that the final pairwise decisions are supported by the studentized range distribution rather than by unadjusted t tests.

R Chart 4: Adjusted p-value Ranking

R Tukey Kramer adjusted p value ranking validation chart
R validation chart ranking adjusted p-values for all Tukey-Kramer pairwise comparisons.

The R adjusted p-value ranking confirms that four comparisons are below alpha .05 after family-wise adjustment. The smallest adjusted p-value belongs to the largest mean separation, 1 vs 3. The comparison 4 vs 3 remains clearly non-significant.

This chart is useful for readers who prefer p-values over q statistics. It communicates that the significant decisions are not based on raw p-values but on Tukey-Kramer adjusted p-values.

R Chart 5: Simultaneous Confidence Intervals

R Tukey Kramer simultaneous confidence intervals validation chart
R validation chart showing simultaneous confidence intervals for Tukey-Kramer mean differences.

The R confidence interval chart confirms that significant pairs have intervals entirely above zero. The non-significant pairs cross zero, which matches the adjusted p-value and q statistic conclusions.

This validation supports a strong reporting style: report the adjusted p-values and also use simultaneous confidence intervals to explain the size and uncertainty of each pairwise difference.

R Chart 6: Pairwise Decision Matrix

R Tukey Kramer pairwise decision matrix validation chart
R validation decision matrix showing significant and non-significant pairwise results.

The R decision matrix validates the same final decision grid. Group 1 differs from every other studytime group, group 2 differs from group 3, and the two upper-level comparisons involving group 4 remain non-significant after adjustment.

The matrix is a helpful quality-control check because any mismatch between the q chart, p-value chart and confidence interval chart would be easy to detect. Here, all decision views agree.

R Chart 7: Homogeneous Subset Letters

R Tukey Kramer homogeneous subset letters validation chart
R validation chart showing homogeneous subset letters for the studytime groups.

The R homogeneous subset chart confirms the final letter grouping: groups 3 and 4 share letter A, group 2 is letter B, and group 1 is letter C. Groups that do not share a letter should be interpreted as significantly different under the Tukey-Kramer family-wise rule.

This is often the most readable final summary for nontechnical readers. It turns six pairwise tests into a simple ordered group pattern.

R Chart 8: Tukey-Kramer Method Report Card

R Tukey Kramer method report card validation chart
R validation report card summarizing the Tukey-Kramer method evidence.

The R method report card validates the ANOVA p-value, q critical value, number of significant pairs, sample-size ratio and pooled MSE. These are the essential pieces needed for transparent reporting.

The agreement between Python and R supports the final conclusion: the Tukey-Kramer test detected four significant pairwise mean differences among studytime groups while controlling the family-wise error rate.

Advertisement
Google AdSense in-content placement reserved here

SPSS, R, Python and Excel Workflows for Tukey Kramer Test

The Tukey Kramer Test can be performed in SPSS, R, Python and Excel. The exact menu labels vary by software, but the logic is the same: run one-way ANOVA, confirm that a post hoc test is justified, calculate or request Tukey-Kramer pairwise comparisons, then interpret adjusted p-values, simultaneous confidence intervals and homogeneous subsets.

SPSS Workflow

StepSPSS ActionPurpose
Open datasetFile > Open > DataLoad the dataset containing G3 and studytime.
Run one-way ANOVAAnalyze > Compare Means > One-Way ANOVASet G3 as dependent variable and studytime as factor.
Request post hoc testPost Hoc > TukeySPSS applies Tukey-style multiple comparisons and handles unequal sample sizes through the appropriate procedure.
Check homogeneityOptions > Homogeneity of variance testReview Levene context before relying on equal-variance post hoc results.
Read outputMultiple Comparisons and Homogeneous SubsetsInterpret adjusted p-values, confidence intervals and subset letters.
Export reportFile > Export PDFSave the SPSS output for verification and reporting.

R Workflow

StepR ActionPurpose
Read dataread.csv()Load the dataset.
Fit ANOVAaov(G3 ~ factor(studytime))Estimate the one-way ANOVA model.
Run Tukey comparisonTukeyHSD()Generate adjusted pairwise comparisons.
Check assumptionsbartlett.test(), fligner.test(), or Levene-style testsCheck variance context before final interpretation.
Plot resultsplot(TukeyHSD(model))Visualize simultaneous confidence intervals.

Python Workflow

StepPython ActionPurpose
Read datapandas.read_csv()Load the dataset.
Fit ANOVAstatsmodels.formula.api.ols()Estimate the ANOVA model.
Get ANOVA tableanova_lm()Extract F statistic, p-value and pooled error term.
Run Tukey comparisonpairwise_tukeyhsd() or SciPy tukey_hsd()Compute adjusted pairwise post hoc results.
Create custom Tukey-Kramer tableUse pooled MSE, unequal-n SE and studentized range critical valueShow transparent q statistics, adjusted p-values and simultaneous CIs.

Excel Workflow

Excel can calculate Tukey-Kramer manually if the ANOVA summary table is available. You need the group means, group sample sizes, pooled MSE, error degrees of freedom, number of groups and a studentized range critical value. The most difficult part is obtaining the correct studentized range critical value and adjusted p-values; many users rely on add-ins, statistical tables or external calculation tools for that step.

Excel InputWhere It Comes FromUse in Tukey-Kramer
Group meansAVERAGEIF or PivotTableUsed in the numerator of the q statistic.
Group sample sizesCOUNTIF or PivotTableUsed in the unequal-n standard error.
Pooled MSEANOVA within-group mean squareUsed as pooled error variance.
q criticalStudentized range table or softwareUsed to judge statistical significance.
Simultaneous CIMean difference ± q critical × SEUsed to interpret direction and uncertainty.

Code Blocks for Tukey Kramer Test

Python Code

import pandas as pd
import statsmodels.api as sm
from statsmodels.formula.api import ols
from statsmodels.stats.multicomp import pairwise_tukeyhsd

# Load data
df = pd.read_csv("dataset.csv")

# Keep valid observations
df = df[["G3", "studytime"]].dropna()
df["studytime"] = df["studytime"].astype("category")

# One-way ANOVA
model = ols("G3 ~ C(studytime)", data=df).fit()
anova_table = sm.stats.anova_lm(model, typ=2)
print(anova_table)

# Tukey-style post hoc comparison
tukey = pairwise_tukeyhsd(
    endog=df["G3"],
    groups=df["studytime"],
    alpha=0.05
)
print(tukey)

# Group summary
summary = df.groupby("studytime")["G3"].agg(["count", "mean", "std"])
print(summary)

R Code

# Load data
df <- read.csv("dataset.csv")

# Keep valid observations
df <- na.omit(df[, c("G3", "studytime")])
df$studytime <- factor(df$studytime)

# One-way ANOVA
model <- aov(G3 ~ studytime, data = df)
summary(model)

# Tukey post hoc comparison
tukey_result <- TukeyHSD(model, "studytime", conf.level = 0.95)
print(tukey_result)

# Plot simultaneous confidence intervals
plot(tukey_result)

SPSS Syntax

ONEWAY G3 BY studytime
  /STATISTICS DESCRIPTIVES HOMOGENEITY
  /POSTHOC = TUKEY ALPHA(0.05)
  /MISSING ANALYSIS.

OUTPUT EXPORT
  /CONTENTS EXPORT=ALL
  /PDF DOCUMENTFILE='Tukey-Kramer-Test-SPSS-Output.pdf'.

Excel Formula Pattern

Mean difference:
=ABS(mean_i - mean_j)

Tukey-Kramer standard error:
=SQRT((MSE/2) * ((1/n_i) + (1/n_j)))

q statistic:
=ABS(mean_i - mean_j) / SQRT((MSE/2) * ((1/n_i) + (1/n_j)))

Simultaneous confidence interval lower:
=Mean_Difference - q_critical * Standard_Error

Simultaneous confidence interval upper:
=Mean_Difference + q_critical * Standard_Error

Decision:
=IF(q_statistic > q_critical, "Significant", "Not significant")

APA Reporting Wording for Tukey Kramer Test

APA-style reporting should first state the ANOVA result and then summarize the post hoc comparisons. The report should include the test name, the reason for using it, the adjusted comparison results and the interpretation of significant pairs. Avoid reporting only “Tukey was significant” because the test is pairwise; each comparison has its own decision.

APA-style example: A one-way ANOVA showed that mean G3 scores differed significantly across studytime groups, F(3, 645) = 15.88, p < .001, η² = .069. Tukey-Kramer post hoc comparisons were used because group sample sizes were unequal. The results showed that group 1 scored significantly lower than group 2, group 4 and group 3. Group 2 also scored significantly lower than group 3. The comparisons between group 2 and group 4 and between group 4 and group 3 were not statistically significant after family-wise adjustment.

For a more detailed report, include adjusted p-values and simultaneous confidence intervals. For example, the difference between studytime group 1 and group 3 was significant, mean difference = 2.38, adjusted p < .001, simultaneous CI [1.40, 3.37]. The comparison between group 4 and group 3 was not significant, mean difference = 0.17, adjusted p = .993, simultaneous CI [-1.42, 1.76].

Common Mistakes in Tukey Kramer Test

MistakeWhy It Is a ProblemBetter Practice
Running Tukey-Kramer without checking ANOVA contextPost hoc tests should be connected to the omnibus model and assumptions.Report ANOVA, MSE, df error and variance context.
Using unadjusted p-values for all pairsMultiple comparisons inflate Type I error.Use adjusted Tukey-Kramer p-values or simultaneous CIs.
Ignoring unequal sample sizesUnequal n changes each pairwise standard error.Use the Tukey-Kramer unequal-n standard error formula.
Calling every different-looking mean significantVisual mean differences may be explained by sampling uncertainty.Use q statistic, adjusted p-value and simultaneous CI decision rules.
Using Tukey-Kramer under serious variance heterogeneityThe method relies on pooled ANOVA MSE.Consider Games-Howell or Tamhane’s T2 if heterogeneity is serious.
Reporting only homogeneous lettersLetters are useful but do not show effect sizes or intervals.Report letters with mean differences, adjusted p-values and confidence intervals.

Downloads and Resources

The following report files and visual outputs support the Tukey Kramer Test example. Use them to verify the Python output, R validation and SPSS reporting.

External References

FAQs About Tukey Kramer Test

What is the Tukey Kramer Test?

The Tukey Kramer Test is a post hoc multiple comparison method used after ANOVA to compare all pairs of group means while controlling the family-wise error rate. It is especially useful when sample sizes are unequal.

When should I use the Tukey Kramer Test?

Use it after a significant one-way ANOVA when you want all pairwise group comparisons and the equal-variance assumption is acceptable. It is particularly suitable when the group sample sizes are not equal.

What does a Tukey Kramer Test tell you?

It tells you which specific pairs of group means differ significantly after adjusting for multiple comparisons. ANOVA tells you that at least one mean differs; Tukey-Kramer tells you where the differences are.

Is Tukey Kramer the same as Tukey HSD?

They are closely related. Tukey-Kramer is commonly described as the unequal-sample-size version of Tukey HSD. With equal sample sizes, the methods are very similar.

What is q in the Tukey Kramer Test?

The q statistic is the studentized range statistic. It divides the absolute pairwise mean difference by the Tukey-Kramer standard error and compares the result with a family-wide q critical value.

How do I interpret adjusted p-values in Tukey Kramer Test?

An adjusted p-value below alpha, usually .05, means the pairwise mean difference is significant after controlling the family-wise error rate across all pairwise comparisons.

Can I do Tukey Kramer Test in Excel?

Yes, but it is easiest when you already have the ANOVA MSE, group means, group sample sizes, error degrees of freedom and studentized range critical value. Excel can calculate the q statistic and confidence intervals manually, but adjusted p-values usually require an add-in or external calculation.

What should I use if variances are unequal?

If variance heterogeneity is serious, consider alternatives such as Games-Howell or Tamhane’s T2. Tukey-Kramer uses pooled ANOVA error variance, so it is best when the equal-variance context is acceptable.

Need help applying this to your own data?

Salar Cafe can help interpret output, clean datasets, review assumptions, build dashboards and explain statistical results ethically.

Need help interpreting your data analysis results?

Contact Salar Cafe
Engr. Muhammad Yar Saqib author profile photo

Engr. Muhammad Yar Saqib

WhatsApp Get Data Analysis Help