Jonckheere-Terpstra Test
Nonparametric test for ordered alternatives across 3+ independent groups (tests for monotonic trend)..
What is it?
Jonckheere-Terpstra Testevaluates if group medians follow a predefined monotonic order (e.g. Dose 1 < Dose 2 < Dose 3).
When to use it
- Ordered Hypothesis: Hypothesized ordered pattern across groups.
- Nonparametric scale: Ordinal or non-normal data violating parametric trends assumptions.
Core Idea
Performs all possible pairwise cross-comparisons. Computes the proportion of pairs matching the expected trend:
Hypotheses
How it works
- Conduct pairwise comparisons for all combinations where i < j.
- Count how many times score in higher group exceeds lower group.
- Sum counts to yield Jonckheere-Terpstra J statistic.
- Test J statistic against expected null mean and variance.
Assumptions
Effect Size
Standardized J statistic represents a non-linear correlation coefficient (similar to Kendall's Tau) indicating monotonic trend strength.
Quick Example
| Dose Group | n | Median Score |
|---|---|---|
| Control | 8 | 12.2 |
| Low Dose | 8 | 18.5 |
| High Dose | 8 | 24.4 (Significant trend) |
Jonckheere-Terpstra Ordered Trend Laboratory
Slide Group 2 and 3 offsets to observe ordered pairwise separation.
| Metric | Value |
|---|---|
| Jonckheere J Stat | 119 |
| Expected J under H0 | 96 |
| Z-statistic | 3.416 |
| p-value | 0.0007 |
Hypotheses
Pragmatic null and alternative hypotheses defined in mathematical notation.
H₀: No ordered trend (all distributions identical or randomly ordered)
Hₐ: Ordered trend exists (e.g., Group1 ≤ Group2 ≤ Group3, with at least one strict inequality)
Tests for ORDERED alternatives (monotonic trend) across groups. More powerful than Kruskal-Wallis when a priori ordering is expected (e.g., dose-response: low < medium < high). IMPORTANT: Like other rank tests, only tests medians when distribution shapes are similar (Divine et al., 2018); otherwise tests stochastic ordering.
Assumptions
The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.
Diagnostics
Checking residual plots and indices to examine model deviations and ensure standard error integrity.
- Boxplots showing ordered groups (visual trend inspection)
- Check for monotonic pattern (medians increase/decrease across ordered groups)
- Verify distribution shapes are similar
- Group medians and IQRs (should show monotonic pattern)
- Scatter plot with group medians overlaid
- Levene's test for homogeneity of variance
- Density plots overlaid by group (check shape similarity)
- Effect size plot (medians with CIs across ordered groups)
Applied Minds
Review concrete study examples, data layout guidelines, and copy executable syntax scripts.
Yoga Dose-Response on Stress (Ordered 4-Group Design)
Research question: Does yoga practice frequency show dose-response relationship with stress reduction? Design: 4 independent groups with ordered yoga frequency (Never, 1x/week, 3x/week, Daily), n=30 per group. Outcome: Perceived Stress Scale (PSS, 0-40, lower = less stress, ordinal). JT tests ordered hypothesis: Never ≥ 1x/week ≥ 3x/week ≥ Daily.
# Jonckheere-Terpstra Test: Yoga dose-response on stress
library(clinfun)
library(tidyverse)
library(rstatix)
set.seed(2025)
data <- data.frame(
yoga_frequency = factor(rep(c("Never", "1x/week", "3x/week", "Daily"), each=30),
levels=c("Never", "1x/week", "3x/week", "Daily")), # Ordered!
stress_pss = c(
round(rnorm(30, 28, 6)), # Never: high stress
round(rnorm(30, 24, 5.5)), # 1x/week: moderate-high
round(rnorm(30, 19, 5)), # 3x/week: moderate-low
round(rnorm(30, 14, 4.5)) # Daily: low stress
)
)
data$stress_pss <- pmin(pmax(data$stress_pss, 0), 40) # Bound 0-40
# Visualize ordered trend
ggplot(data, aes(x=yoga_frequency, y=stress_pss, fill=yoga_frequency)) +
geom_boxplot() +
stat_summary(fun=median, geom="line", aes(group=1), color="red", size=1) +
stat_summary(fun=median, geom="point", color="red", size=3) +
labs(title="Dose-Response: Yoga Frequency → Stress(Ordered Trend)",
subtitle="Red line shows median trend",
x="Yoga Practice Frequency(Ordered)", y="Perceived Stress(PSS)") +
theme_minimal() + theme(legend.position="none")
# Descriptive stats by group
data %>%
group_by(yoga_frequency) %>%
summarise(n=n(), Median=median(stress_pss), IQR=IQR(stress_pss))
# Jonckheere-Terpstra Test
# Convert ordered factor to numeric for clinfun::jonckheere.test
yoga_numeric <- as.numeric(data$yoga_frequency) # 1=Never, 2=1x/week, 3=3x/week, 4=Daily
jt_result <- jonckheere.test(data$stress_pss, yoga_numeric, alternative="decreasing")
print(jt_result)
# Alternative: use DescTools::JonckheereTerpstraTest
# Effect size: Kendall's tau for trend
tau <- cor.test(yoga_numeric, data$stress_pss, method="kendall")
cat("\nKendall's tau(trend effect size):", round(tau$estimate, 3), "\n")
cat("Interpretation: |tau| = .10 (small), .30 (medium), .50 (large)\n\n")
# Compare to Kruskal-Wallis (non-directional)
kw_result <- kruskal.test(stress_pss ~ yoga_frequency, data=data)
cat("Kruskal-Wallis(non-directional) p =", round(kw_result$p.value, 4), "\n")
cat("JT(directional trend) p =", round(jt_result$p.value, 4), "\n")
cat("JT is more powerful when trend hypothesis is correct\n\n")
# APA Report
cat("=== APA Report ===\n")
cat(paste0(
"A Jonckheere-Terpstra test was conducted to test the a priori hypothesis of ",
"an ordered dose-response relationship between yoga practice frequency and stress. ",
"Groups were ordered: Never ≥ 1x/week ≥ 3x/week ≥ Daily practice. There was a ",
"significant decreasing trend in stress across increasing yoga frequency, ",
"JT = ", round(jt_result$statistic, 2), ", p < .001, Kendall's tau = ",
round(tau$estimate, 2), " (large effect). Median stress scores decreased monotonically: ",
"Never(Mdn=28), 1x/week(Mdn=24), 3x/week(Mdn=19), Daily(Mdn=14), supporting ",
"a dose-response relationship between yoga frequency and stress reduction."
))JT statistic = 9875, p < .001, Kendall's tau = -.68 (large). Significant ordered trend: stress decreases monotonically with increasing yoga frequency. Daily practice (Mdn=14) showed lowest stress, Never (Mdn=28) highest. JT more powerful than Kruskal-Wallis (p=.002 vs p<.001) because it leverages a priori ordering. Supports dose-response hypothesis.
Alternatives
Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.
- Kruskal-Wallis — Return to the omnibus rank audit if the trend hypothesis is violated.
- Linear Contrast ANOVA — Reclaim higher efficiency by utilizing raw scores and ordered mean-comparisons.
- Monte Carlo JT — Resample the null distribution to calculate exact significance for discrete ordered scales.
Post-hoc
Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.
Post-hoc pairwise tests defined for this model.
Jonckheere-Terpstra assumes an order. Post-hoc forensics should verify that the order was respected—JT loses authority if the data 'Wiggles' instead of 'Trends'.
Effect Size
Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.
Range: -1 to +1. Small: .10, Medium: .30, Large: .50 (Cohen, 1988 adapted). Measures strength of monotonic association between ordered groups and outcome
Z-score version of JT statistic. Standardized for sample size. Larger |Z| = stronger trend
Range: -1 to +1. Similar to Kendall's tau but based on ranks. Slightly larger in magnitude than tau for same data
0.2
0.5
0.8
Sample Size
Guidelines for minimum sample requirements and power analysis parameters.
At least 5 observations per group. For k=3 groups, minimum n=15 total. Smaller samples: use exact permutation version
| Effect Size | Parameters | Required n |
|---|---|---|
| Small Effect | Kendall's tau = .10 | n ≈ 300 total |
| Medium Effect | Kendall's tau = .30 | n ≈ 90 total |
| Large Effect | Kendall's tau = .50 | n ≈ 45 total |
Reporting
How to compile statistical results into publication prose matching APA and journal style guides.
A Jonckheere-Terpstra test was conducted to test the a priori hypothesis of an ordered increasing/decreasing trend in outcome across k ordered groups. Groups were ordered: list ordering, e.g., Group1 < Group2 < Group3. State assumption checks: 'Distributions had similar shapes' OR 'noted for stochastic ordering interpretation'. There was a significant/non-significant increasing/decreasing trend, JT = X.XX, p = .XXX, Kendall's tau = .XX interpret effect size. If significant: Median outcome increased/decreased monotonically across groups: list medians. Conclude with interpretation in research context.
- JT statistic or standardized Z-score
- p-value
- Effect size (Kendall's tau or Spearman's rho)
- Direction of ordering tested (increasing/decreasing)
- Medians (or medians + IQRs) for each ordered group
- Statement confirming a priori ordering hypothesis
- Justification for using JT over Kruskal-Wallis
Manuscript Lab
Copy standard summary tables and forensic reporting grids to outline analysis details.
| Group | Median | Mean Rank | J (Statistic) | z | p (Trend) |
|---|---|---|---|---|---|
| Low | 45 | 32.4 | 1845 | 4.12 | < .001 |
| Med | 52 | 45.1 | — | — | — |
| High | 65 | 57.5 | — | — | — |
The Step-Wise Count. Sums the number of times a person in a higher group ranks higher than someone in a lower group.
Linear Median Probability. Proves that as intensity increases, performance medians rise in a systematic ladder.
Command Center
Syntax libraries and function parameters for executing calculations in stats packages.
# 1. Execute Jonckheere-Terpstra Test for ordered alternatives
clinfun::jonckheere.test(x, g, alternative = 'two.sided')Jonckheere-Terpstra assumes a specific monotonic ordering. If the trend is non-monotonic (e.g. U-shaped), JT loses power and Kruskal-Wallis should be used.
# Run pairwise Wilcoxon post-hoc comparisons to locate the trend shift
rstatix::wilcox_test(df, score ~ group, p.adjust.method = 'bonferroni')Common Mistakes
Analytical caveats and corrections to maintain modeling integrity.
References
Scholarly lineage and citation keys grounding the statistical framework.