Atlas
statminds
NonparametricThe underlying model family class (e.g. GLM, linear model, categorical matrix, log-linear).Parametric ReferenceStatistical methods that assume a specific probability distribution family (typically normal).12-stage workflow

Wald-Wolfowitz Runs Test (Two-Sample)

Tests if two independent samples come from identical distributions by analyzing the sequence pattern (runs) in combined ranked data; detects differences in location, scale, or shape..

Model familyNonparametric
Hypothesistwo-tailed
AliasesRuns Test for Two Samples · Two-Sample Runs Test
G1
association
G2
description
Visual Overview Dashboard
1

What is it?

Wald-Wolfowitz Runs Test compares the distributions of two independent groups by evaluating the run sequence of sorted combined group labels.

2

When to use it

  • Two Samples: General distribution equivalence test (shapes, spreads, locations).
  • Nonparametric fallback: Outlier-resistant alternative to parametric comparisons.
3

Core Idea

Combines and sorts both groups. If their distributions differ, they cluster separately, yielding very few runs of group labels:

Group 1 runGroup 2 run
4

Hypotheses

H0: Group 1 and Group 2 distributions are identical
Ha: Group distributions differ in location, spread, or shape
5

How it works

  1. Combine Group 1 and Group 2 data into a single list and sort.
  2. Substitute each score with its corresponding group label (1 or 2).
  3. Count consecutive sequences (runs) of identical labels.
  4. Low runs count indicates significant separation.
6

Assumptions

📊 Continuity: Step functions assume no ties.
👤 Independence: Unrelated groups.
7

Effect Size

Proportion of observed runs to expected runs under H0. Ratios < 0.6 indicate substantial distribution divergence.

8

Quick Example

SeqObserved RunsExpected Runs
1 1 1 2 2 224.0 (Significant)
1 2 1 2 1 264.0 (Identical)
Interactive Sandbox

Wald-Wolfowitz Two-Sample Runs Laboratory

Shift Group 2's mean to see sorted combined group label clustering.

Presets
Group 2 Mean Shift8.0
Size G1 (N1)15
Size G2 (N2)15
Sorted combined group label timeline (Amber: G1, Green: G2)Red lines show run boundaries
Calculations Output
MetricValue
Total Combined N30
Observed Runs (R)8
Expected Runs E(R)16.00
p-value (two-tailed)0.0032
Statistical Verdict
✅ Different Distributions
Observed runs count deviates significantly from expected random shuffling rate (R = 8, p = 0.0032). Reject H0.
01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

A hypothesis is a question sharpened to a point. Ambiguity is the enemy of inference.
Logic Core
Null · H₀

H₀: The two samples come from identical distributions (randomly intermixed)

Alternative · Hₐ

Hₐ: The two samples come from different distributions (systematic clustering)

Why it matters two-tailed

Tests whether combined data are randomly mixed or systematically clustered. Few runs suggest clustering (distribution differences); many runs suggest oscillation. Detects location, scale, and shape differences unlike Mann-Whitney which primarily tests location shift.

02Model diagnostics

Assumptions

The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.

Build your analysis on rock, not sand. Verify the mathematical foundation before building the model.
Integrity Shield
6
Assumptions
0
Critical / High Severity
How to check
Inspect variable type; verify values can be ordered from lowest to highest
If violated
If nominal (no ordering) → use chi-square test of independence or Fisher's exact test
How to check
Design review; confirm no subject appears in both groups; check for matching/pairing
If violated
If paired/matched data → use sign test or Wilcoxon signed-rank test. If repeated measures → use Friedman test. If clustered → account for clustering in analysis
How to check
Quick
Count observations per group. If n₁ ≥ 10 AND n₂ ≥ 10, normal approximation is accurate
Rigorous
For small samples (n₁ < 10 or n₂ < 10), use exact tables or permutation test. Total N should be ≥20 for reliable asymptotic results
If violated
If n₁ < 10 or n₂ < 10: (1) Use exact permutation distribution or lookup tables for runs test; (2) Use Fisher's exact test if comparing proportions; (3) Consider combining data from multiple studies (meta-analysis); (4) Interpret with caution due to low power. With very small samples, any test has limited power
How to check
Quick
Verify outcome is quantitative or ordinal. Check for ties—extensive ties reduce test power but do not invalidate test
Rigorous
Calculate proportion of tied values. If >25% ties, consider using tie-correction methods or alternative tests. Examine if ties are due to measurement precision (acceptable) or categorical data (problematic)
If violated
If many ties (>25%): (1) Use Mann-Whitney U (handles ties better); (2) Apply mid-rank method for ties; (3) If ties due to discrete categories, consider chi-square test; (4) If ties due to measurement precision, acceptable to proceed but report tie percentage. Runs test automatically handles ties using mid-ranking
kolmogorov smirnov
How to check
Quick
Review data collection protocol. Ensure runs test is applied to rank-ordered data (not collection order). Verify samples were collected independently
Rigorous
Distinguish between (1) single-sample runs test (tests randomness of sequence over time—not used here) and (2) two-sample runs test (tests distribution similarity—used here). For two-sample test, data are combined and ranked, so collection order is irrelevant
If violated
Two-sample runs test operates on ranks of combined data, not collection order, so temporal sequence issues are not relevant. If concerned about temporal trends within groups, check for time effects before comparing groups. The test reorders data by rank, eliminating collection order effects
How to check
Quick
Check variable type. Continuous and ordinal data are appropriate. Avoid with purely nominal data
Rigorous
Examine distribution: if data have >10 unique values, ranking is informative. If <5 unique values (e.g., Likert 1-5), test may have reduced power but is still valid. For binary outcomes, use different test
If violated
If binary outcome (2 categories): use chi-square test or Fisher's exact test. If nominal (unordered categories): use chi-square test of independence. If ordinal with very few levels (<5), consider Mann-Whitney U as more robust alternative
03Residual Forensics

Diagnostics

Checking residual plots and indices to examine model deviations and ensure standard error integrity.

Trust, but verify. The outliers often hold more truth than the averages.
System Health
Essential checks
  1. Visual comparison of distributions (boxplots, histograms by group)
  2. Check combined ordered sequence for clustering pattern (run sequence plot)
  3. Compare medians and spreads (IQR) between groups
  4. Calculate number of runs and compare to expected (E[R] = 1 + (2n₁n₂)/(n₁+n₂))
  5. Compute effect size (standardized runs statistic or Cohen's d for comparison)
Recommended checks
  1. Overlay density plots to visualize distribution differences (location, scale, shape)
  2. Empirical cumulative distribution function (ECDF) plots to detect all distribution differences
  3. Compare runs test with Mann-Whitney U (M-W tests location primarily; runs tests all aspects)
  4. Check for outliers that might create artificial runs
  5. Sensitivity analysis: compare results with/without extreme values
  6. Calculate overlap coefficient (proportion of distributions overlapping)
  7. Quantile-quantile (Q-Q) plot comparing group distributions
  8. Bootstrap confidence intervals for difference in medians or means
  9. Check skewness and kurtosis differences between groups
04Live Instances

Applied Minds

Review concrete study examples, data layout guidelines, and copy executable syntax scripts.

Theory is the map. Practice is the terrain. Simulation bridges the gap.
Applied Wisdom
Example 01

Reaction Time Comparison Between Two Training Methods

Research question: Do two training methods produce different distributions of reaction times? Design: Between-subjects (n=50, 25 per group). Outcome: Reaction time in milliseconds (continuous, right-skewed). Runs test used to detect any distribution differences (not just location), as training might affect variability or shape, not only central tendency.

GroupsMethod_A · Method_B
Total n50
Outcome ScaleReaction time (ms, continuous, right-skewed)
# ==============================================================================
# Wald-Wolfowitz Runs Test: Reaction Time Comparison
# Research Question: Do two training methods produce different RT distributions?
# ==============================================================================

library(tidyverse)      # Data manipulation and visualization
library(randtests)      # runs.test() for Wald-Wolfowitz
library(DescTools)      # WaldWolfTest() - alternative implementation
library(effectsize)     # Effect size calculations
library(ggpubr)         # Publication-ready plots

# Generate simulated data (n = 50, 25 per group)
set.seed(2025)
data <- data.frame(
  method = rep(c("Method_A", "Method_B"), each=25),
  reaction_time = c(
    rgamma(25, shape=4, scale=50),    # Method A: faster, less variable
    rgamma(25, shape=3, scale=70)     # Method B: slower, more variable
  )
)

data$method <- factor(data$method, levels = c("Method_A", "Method_B"))

# ==============================================================================
# STEP 1: DESCRIPTIVE STATISTICS
# ==============================================================================

cat("\n=== DESCRIPTIVE STATISTICS ===\n")

descriptives <- data %>%
  group_by(method) %>%
  summarise(
    n = n(),
    mean = mean(reaction_time),
    sd = sd(reaction_time),
    median = median(reaction_time),
    IQR = IQR(reaction_time),
    min = min(reaction_time),
    max = max(reaction_time)
  )
print(descriptives)

# ==============================================================================
# STEP 2: ASSUMPTION CHECKING
# ==============================================================================

cat("\n=== ASSUMPTION CHECKS ===\n")

# Assumption 1: Independence
cat("1. Independence: Design review confirms between-subjects(independent groups)\n")

# Assumption 2: Sample size (n₁, n₂ ≥ 10 for normal approximation)
cat("\n2. Sample Size Check:\n")
cat(sprintf("   Method A: n = %d(≥10 ✓)\n", sum(data$method == "Method_A")))
cat(sprintf("   Method B: n = %d(≥10 ✓)\n", sum(data$method == "Method_B")))
cat("   Normal approximation is valid.\n")

# Assumption 3: Check for ties
cat("\n3. Tied Values Check:\n")
n_ties <- sum(duplicated(data$reaction_time))
pct_ties <- (n_ties / nrow(data)) * 100
cat(sprintf("   Ties: %d(%.1f%% of data)\n", n_ties, pct_ties))
if(pct_ties < 10) {
  cat("   Ties are minimal(<10%), test is appropriate.\n")
} else {
  cat("   Warning: >10% ties may reduce power. Consider Mann-Whitney U.\n")
}

# ==============================================================================
# STEP 3: VISUALIZATIONS
# ==============================================================================

cat("\n=== GENERATING VISUALIZATIONS ===\n")

# Visualization 1: Boxplots
p1 <- ggplot(data, aes(x=method, y=reaction_time, fill=method)) +
  geom_boxplot(alpha=0.7) +
  geom_jitter(width=0.2, alpha=0.4, size=2) +
  labs(title="Reaction Time by Training Method",
       x="Training Method", y="Reaction Time(ms)") +
  theme_minimal() +
  theme(legend.position="none")
print(p1)

# Visualization 2: Density plots (check location AND scale differences)
p2 <- ggplot(data, aes(x=reaction_time, fill=method)) +
  geom_density(alpha=0.5) +
  labs(title="Distribution Comparison: Density Plots",
       subtitle="Runs test detects differences in location, scale, and shape",
       x="Reaction Time(ms)", y="Density") +
  theme_minimal()
print(p2)

# Visualization 3: ECDF plot (empirical cumulative distribution)
p3 <- ggplot(data, aes(x=reaction_time, color=method)) +
  stat_ecdf(geom="step", size=1.2) +
  labs(title="Empirical Cumulative Distribution Functions",
       subtitle="Separation indicates distribution differences",
       x="Reaction Time(ms)", y="Cumulative Probability") +
  theme_minimal()
print(p3)

# Visualization 4: Run sequence plot
cat("\n4. Creating Run Sequence Plot...\n")
# Combine and rank data
data_combined <- data %>%
  arrange(reaction_time) %>%
  mutate(
    rank = row_number(),
    group_code = ifelse(method == "Method_A", "A", "B")
  )

p4 <- ggplot(data_combined, aes(x=rank, y=reaction_time, color=method, shape=method)) +
  geom_point(size=3, alpha=0.7) +
  geom_line(aes(group=1), color="gray80", size=0.5) +
  labs(title="Run Sequence: Ordered Data by Rank",
       subtitle="Clustering of colors indicates distribution differences",
       x="Rank(ordered by RT)", y="Reaction Time(ms)") +
  theme_minimal()
print(p4)

# ==============================================================================
# STEP 4: WALD-WOLFOWITZ RUNS TEST
# ==============================================================================

cat("\n=== WALD-WOLFOWITZ RUNS TEST ===\n")

# Extract group data
group_a <- data %>% filter(method == "Method_A") %>% pull(reaction_time)
group_b <- data %>% filter(method == "Method_B") %>% pull(reaction_time)

# Method 1: randtests package
cat("\nMethod 1: randtests::runs.test\n")
runs_result <- runs.test(x=group_a, y=group_b, alternative="two.sided")
print(runs_result)

# Method 2: DescTools package (alternative)
cat("\nMethod 2: DescTools::WaldWolfTest\n")
ww_result <- WaldWolfTest(x=group_a, y=group_b)
print(ww_result)

# Extract key statistics
n1 <- length(group_a)
n2 <- length(group_b)
runs_observed <- runs_result$statistic
runs_expected <- 1 + (2*n1*n2)/(n1+n2)
runs_sd <- sqrt((2*n1*n2*(2*n1*n2 - n1 - n2)) / ((n1+n2)^2 * (n1+n2-1)))
z_stat <- (runs_observed - runs_expected) / runs_sd
p_value <- runs_result$p.value

cat("\n--- Test Summary ---\n")
cat(sprintf("n₁ (Method A): %d\n", n1))
cat(sprintf("n₂ (Method B): %d\n", n2))
cat(sprintf("Runs observed: %.0f\n", runs_observed))
cat(sprintf("Runs expected(H₀): %.2f\n", runs_expected))
cat(sprintf("Standard deviation: %.2f\n", runs_sd))
cat(sprintf("Z-statistic: %.3f\n", z_stat))
cat(sprintf("p-value: %.4f\n", p_value))
cat(sprintf("Result: %s at α = .05\n", 
    ifelse(p_value < 0.05, "SIGNIFICANT", "Not significant")))

# ==============================================================================
# STEP 5: EFFECT SIZE
# ==============================================================================

cat("\n=== EFFECT SIZE ===\n")

# Standardized runs effect size
standardized_runs <- (runs_observed - runs_expected) / runs_sd
cat(sprintf("Standardized runs statistic: %.3f\n", standardized_runs))
cat("Interpretation: |z| < 1.96 (small), 1.96-2.58 (medium), > 2.58 (large)\n")

# Cohen's d for comparison (location effect)
cohen_d <- (mean(group_a) - mean(group_b)) / 
           sqrt(((n1-1)*var(group_a) + (n2-1)*var(group_b)) / (n1+n2-2))
cat(sprintf("\nCohen's d(for comparison): %.3f\n", cohen_d))
cat("Note: Runs test is sensitive to ALL distribution differences, not just location.\n")

# Overlap coefficient
min_max_a <- max(group_a)
max_min_b <- min(group_b)
overlap <- sum(group_a > max_min_b & group_a < min_max_a) / (n1 + n2)
cat(sprintf("\nDistribution overlap: %.1f%%\n", overlap*100))

# ==============================================================================
# STEP 6: COMPARE WITH MANN-WHITNEY U TEST
# ==============================================================================

cat("\n=== COMPARISON WITH MANN-WHITNEY U TEST ===\n")
cat("Mann-Whitney tests primarily location shift; Runs test detects ALL differences.\n\n")

mw_result <- wilcox.test(group_a, group_b, alternative="two.sided")
cat("Mann-Whitney U Test:\n")
cat(sprintf("W = %.1f, p = %.4f\n", mw_result$statistic, mw_result$p.value))

cat("\nInterpretation:\n")
if(p_value < 0.05 && mw_result$p.value < 0.05) {
  cat("Both tests significant: distributions differ(likely in location AND scale/shape).\n")
} else if(p_value < 0.05 && mw_result$p.value >= 0.05) {
  cat("Runs significant, M-W not: distributions differ in scale/shape, not location.\n")
} else if(p_value >= 0.05 && mw_result$p.value < 0.05) {
  cat("M-W significant, Runs not: location shift present, but distributions similarly shaped.\n")
} else {
  cat("Both tests non-significant: distributions are similar.\n")
}

# ==============================================================================
# STEP 7: INTERPRETATION
# ==============================================================================

cat("\n=== INTERPRETATION ===\n")
cat(sprintf(
  "The Wald-Wolfowitz runs test showed %s difference between the two training\n",
  ifelse(p_value < 0.05, "a significant", "no significant")))
cat(sprintf(
  "methods, Z = %.3f, p = %.4f. The observed number of runs(%.0f) was %s\n",
  z_stat, p_value, runs_observed,
  ifelse(runs_observed < runs_expected, "fewer than expected", "similar to expected")))
cat(sprintf(
  "under the null hypothesis(expected: %.2f), indicating %s.\n",
  runs_expected,
  ifelse(runs_observed < runs_expected, "clustering(distribution differences)", "random intermixing")))

if(p_value < 0.05) {
  cat("\nThe distributions differ in location(Method A faster: M=%.1f vs M=%.1f)\n",
      mean(group_a), mean(group_b))
  cat("and/or variability(Method A SD=%.1f vs Method B SD=%.1f).\n",
      sd(group_a), sd(group_b))
  cat("This comprehensive distribution difference(detected by runs test) suggests\n")
  cat("Method A produces more consistent, faster reaction times than Method B.\n")
}

# ==============================================================================
# APA REPORTING TEMPLATE
# ==============================================================================

cat("\n=== APA-STYLE REPORTING ===\n")
cat("A Wald-Wolfowitz runs test was conducted to compare reaction time distributions\n")
cat("between two training methods(Method A: n=25, Method B: n=25). The test evaluates\n")
cat("whether the two samples are randomly intermixed(null hypothesis) or systematically\n")
cat(sprintf("clustered(alternative). Results showed %s, Z = %.3f,\n",
    ifelse(p_value < 0.05, "a significant difference", "no significant difference"),
    z_stat))
cat(sprintf("p = %.4f, with %.0f runs observed versus %.2f expected under random mixing.\n",
    p_value, runs_observed, runs_expected))
if(p_value < 0.05) {
  cat(sprintf("Method A(M=%.1f ms, SD=%.1f) produced faster and less variable reaction times\n",
      mean(group_a), sd(group_a)))
  cat(sprintf("than Method B(M=%.1f ms, SD=%.1f), d = %.2f (large effect). The runs test detected\n",
      mean(group_b), sd(group_b), abs(cohen_d)))
  cat("comprehensive distribution differences beyond location shift alone, suggesting\n")
  cat("Method A produces superior and more consistent performance.\n")
}
Interpretation Blueprint

Z = -2.45, p = .014. Observed 18 runs vs. 26 expected, indicating clustering (systematic distribution differences). Method A showed faster (M=195ms) and less variable (SD=48ms) performance than Method B (M=215ms, SD=72ms), d = 0.34. Runs test detected comprehensive distribution differences beyond location alone.

05Tactical Pivots

Alternatives

Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.

When the path is blocked, pivot. Rigor is not rigidity; it is the intelligent adaptation to reality.
Adaptive Strategy
Measurement Precision Ladder Ideal · Continuous / Ratio
Ratio
Maintain W-W logic. Optimal for auditing if two samples share the same global distribution (mean, shape, and variance).
Peak Sensitivity
Interval
Ideal for Profile Forensics. Ensure the joint ranking preserves the 'Sequence' of occurrences.
Standard Robustness
Ordinal / Nominal
Abandon W-W. Use Chi-Square Homogeneity to model profile parity across categories.
Identity Only
Temporal Trajectory Audit Static Distributional Snapshot
Static Audit
Joint sequence.
Stay with Wald-Wolfowitz. Identify if one group 'Clumps' at specific levels of the distribution.
Sequential Shift
Randomness audit.
Pivot to standard Runs Test to model the serial independence of a single binary sequence.
Adaptive Technical Safeguards · adaptive safeguards
focus on location only
  • Mann-Whitney U Test — Switch if you specifically need to test for a 'Shift in Median' rather than global distribution equality.
sensitivity to shape
  • Kolmogorov-Smirnov Test — Use the KS strike for higher sensitivity to deviations in the center of the distribution.
extreme ties
  • Exact Permutation Strike — Use Monte Carlo simulations to calculate significance when many ranks are identical.
06Adjusted Comparisons

Post-hoc

Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.

The omnibus test opens the door; post-hoc analysis explores the room.
Forensic Detail
Adjusted Comparisons
  • Compare with Mann-Whitney U (tests location shift)
  • Compare with Kolmogorov-Smirnov (tests any distributional difference)
  • Use exact vs asymptotic p-values for small samples
  • Examine number of runs to characterize difference type
  • Combine with graphical methods (Q-Q plots, density plots)
Interpretation Guidelines

Wald-Wolfowitz runs test compares two distributions. Post-hoc tests are not applicable.

07Standardized scale impact

Effect Size

Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.

Significance is noise. Magnitude is the signal. Measure the impact, not just the probability.
Impact Magnitude

Z = (R - E[R]) / SD(R), where R = observed runs, E[R] = 1 + (2n₁n₂)/(n₁+n₂), SD(R) = sqrt((2n₁n₂(2n₁n₂-n₁-n₂))/((n₁+n₂)²(n₁+n₂-1))). Interpretation: |Z| < 1.96 (small), 1.96-2.58 (medium), > 2.58 (large effect at α=.05). Negative Z indicates fewer runs (clustering); positive Z indicates more runs (oscillation).

d = (M₁ - M₂) / SDpooled. Useful for comparing location component: |d| = 0.2 (small), 0.5 (medium), 0.8 (large). Note: Runs test is sensitive to ALL distribution differences, not just location, so Cohen's d only captures one component.

Proportion of values in overlapping range of distributions. 100% = complete overlap (distributions identical), 0% = no overlap (completely separated). Provides intuitive measure of distribution similarity.

Var₁/Var₂ or SD₁/SD₂. Quantifies scale differences. Ratio close to 1.0 indicates similar spreads; ratio >> 1 indicates one group has much greater variability. Useful when runs test detects differences but Mann-Whitney does not (indicating scale not location difference).

Recommended Metric: Report standardized runs statistic (Z) as primary effect size. Supplement with Cohen's d for location and variance ratio for scale when interpreting what aspect of distributions differs. Overlap coefficient provides intuitive practical interpretation.
Small
0.2
Medium
0.5
Large
0.8
0.50
Report standardized runs statistic (Z) as primary effect size. Supplement with Cohen's d for location and variance ratio for scale when interpreting what aspect of distributions differs. Overlap coefficient provides intuitive practical interpretation.
Recommended Measure
4
Available Metrics
ReportUse Report standardized runs statistic (Z) as primary effect size. Supplement with Cohen's d for location and variance ratio for scale when interpreting what aspect of distributions differs. Overlap coefficient provides intuitive practical interpretation. to represent clinical impact magnitude.
08Statistical Power

Sample Size

Guidelines for minimum sample requirements and power analysis parameters.

An underpowered study is an ethical failure. Respect the data by collecting enough of it.
Power Protocol
Floor Requirements

Each group should have n ≥ 10 for normal approximation to be accurate. With smaller samples (n < 10), use exact permutation test or lookup tables for critical values.

Effect SizeParametersRequired n
Small EffectZ ≈ 0.3Total N ≈ 350
Medium EffectZ ≈ 0.5Total N ≈ 130
Large EffectZ ≈ 0.8Total N ≈ 50
Key considerations

Runs test power depends on TYPE of distribution difference (location, scale, or shape). Power is highest for location shifts, moderate for scale differences, lower for pure shape differences. Extensive ties (>25%) reduce power by 10-20%. Unequal group sizes acceptable but reduce power; aim for balanced design.

G*Power StrategyNo standard power analysis software for runs test. Use simulation or bootstrap methods. As approximation, power is comparable to Mann-Whitney U test (asymptotic relative efficiency ≈ 1.0 for location shifts).
09APA narrative blueprint

Reporting

How to compile statistical results into publication prose matching APA and journal style guides.

Data does not speak for itself. It requires a translator. Be clear, be precise, be honest.
Narrative Arc
Worked APA paragraph example
A Wald-Wolfowitz runs test compared reaction time distributions between two training methods (Method A: n=25, Method B: n=25). This test evaluates whether samples are randomly intermixed or systematically clustered, detecting differences in location, scale, or shape. Results showed a significant difference, Z = -2.45, p = .014, with 18 runs observed versus 26 expected under the null hypothesis of random mixing. Fewer runs indicates clustering, suggesting systematic distribution differences. Method A (M=195 ms, SD=48 ms, Mdn=190 ms) produced faster and less variable reaction times than Method B (M=215 ms, SD=72 ms, Mdn=210 ms), Cohen's d = 0.34 (medium effect), variance ratio = 2.25. Mann-Whitney U test was also significant (W=185, p=.021), indicating both location and scale differences. The runs test detected comprehensive distribution differences beyond location alone, demonstrating Method A produces superior and more consistent performance.
Reusable template

A Wald-Wolfowitz runs test was conducted to compare outcome distributions between Group 1 (n=X) and Group 2 (n=X). The test evaluates whether the two samples are randomly intermixed (null hypothesis) or systematically clustered (alternative). Results showed a significant/no significant difference, Z = X.XX, p = .XXX, with X runs observed versus X.XX expected under random mixing. If significant: The Group 1 (M=XX, SD=XX, Mdn=XX) showed direction of difference compared to Group 2 (M=XX, SD=XX, Mdn=XX), indicating comprehensive distribution differences in location/scale/shape. Compare with Mann-Whitney if relevant to clarify what aspect differs. Conclude with interpretation.

Essential statistics to report
  • Z-statistic
  • p-value
  • number of runs observed
  • number of runs expected
  • n₁ and n₂ (sample sizes)
  • descriptive statistics (means, SDs, medians, IQRs) for both groups
  • effect size (standardized runs statistic, Cohen's d, and/or variance ratio)
  • comparison with Mann-Whitney U if relevant to clarify distribution aspect
10Exhibit Builder

Manuscript Lab

Copy standard summary tables and forensic reporting grids to outline analysis details.

Table 1: Wald-Wolfowitz Runs Test for Sample Identity
Observed RunsExpected Runsz-statisticp-valueResult
2850.5-4.12< .001Significantly Different Shapes
Note. N1 = 50, N2 = 50. Comparing Distribution A vs. Distribution B.
p < .001Confirms 'Pure' Distributional Difference. The two groups are not just different in means; their entire distributional shapes are distinct and non-overlapping.
Header glossary

The 'Mixing' count. We combine both samples and sort them. If they are from the same population, they should be well-mixed (high runs). If different, they will cluster (low runs).

The Deviation Meter. Measures how many standard errors the mixing level is away from perfect randomness.

11Algorithmic Logic

Command Center

Syntax libraries and function parameters for executing calculations in stats packages.

Code is the modern laboratory. Clean execution ensures reproducible discovery.
Execution Engine
# 1. Execute Two-Sample Runs Test
randtests::runs.test(combined_vector)

# 2. Sequential Independence Test
tseries::runs.test(factor(df$y > median(df$y)))
Library stack
R
randteststseries
Python
statsmodels.stats.diagnostic
Elite Forensic Strike

The Runs test is the most general test for distribution equality. It assumes NOTHING about shape, mean, or variance. It only looks at 'Clustering' in the data sequence.

# Audit for Autocorrelation in Residuals
randtests::runs.test(residuals(model))
12The Over-adjustment Trap

Common Mistakes

Analytical caveats and corrections to maintain modeling integrity.

Wisdom is learning from the failures of others. Anticipate the error before it occurs.
Defensive Logic
Why it's wrong
Single-sample runs test (runs test for randomness) tests whether a SEQUENCE is random (e.g., coin flips: HHTTHTHH). Two-sample runs test compares DISTRIBUTIONS of two independent groups. They are completely different tests with different hypotheses and applications. Using single-sample runs test on two groups (e.g., testing if group labels appear randomly) answers wrong question.
The correction
Two-sample Wald-Wolfowitz test: Combine two groups, rank all values, see if groups are randomly intermixed or clustered. Tests: Do distributions differ? Single-sample runs test: Analyze one sequence over time for randomness. Tests: Is sequence random? For comparing two independent groups → use two-sample runs test (Wald-Wolfowitz). For testing randomness of one sequence → use single-sample runs test.
Why it's wrong
Runs test is sensitive to ALL distribution differences: location (median/mean), scale (variance/spread), and shape (skewness, modality). If significant, you cannot assume it's only a location difference. Groups could have identical medians but different spreads (scale), or identical means but different shapes (e.g., unimodal vs bimodal), and runs test would still be significant. This is actually an ADVANTAGE (comprehensive test) but requires careful interpretation.
The correction
ALWAYS examine multiple aspects: (1) Compare medians/means (location), (2) Compare SDs/IQRs (scale), (3) Overlay density plots (shape). If runs test significant but Mann-Whitney not → scale or shape difference, not location. If both significant → likely location AND scale/shape. Report what aspect(s) differ. Use Levene's test to check variance equality. Runs test advantage: detects differences M-W might miss.
Why it's wrong
Runs test requires INDEPENDENT samples. With paired data (e.g., pre-post, matched pairs), observations are not independent—each subject contributes to both groups, violating independence assumption. Using runs test inflates Type I error and loses power by ignoring within-subject correlation. For paired data, differences within pairs should be analyzed, not distributions across groups.
The correction
For paired data: (1) If outcome is continuous/ordinal and non-normal → Wilcoxon signed-rank test; (2) If binary outcome → McNemar's test or sign test; (3) If testing randomness of difference sequence → single-sample runs test on differences. Always check: is each subject in ONE group (independent → runs test) or BOTH groups (paired → paired test)?
Why it's wrong
Runs test detects ANY distribution difference; Mann-Whitney primarily tests location. When runs test is significant, you don't know if it's location, scale, shape, or combination. Not comparing with Mann-Whitney (or examining descriptive statistics) prevents understanding WHAT aspect of distributions differs, limiting actionable interpretation.
The correction
ALWAYS run both tests and compare: (1) Runs significant + M-W significant → location AND scale/shape differ; (2) Runs significant + M-W not significant → scale or shape differs, NOT location (critical finding—groups have similar central tendency but different spreads/shapes); (3) Runs not significant + M-W significant → unlikely, suggests location shift with similar shapes; (4) Both not significant → distributions similar. Supplement with Levene's test (variance equality) and visual inspection (density plots).
Why it's wrong
Tied values (identical scores) receive mid-ranks, which can affect run counting if ties span both groups. With many ties (>25% of data), test power decreases, and in extreme cases (>50% ties), test becomes unreliable. Ties often indicate measurement issues (e.g., ceiling/floor effects, coarse measurement) that may require different analysis approach.
The correction
Check proportion of ties: count(duplicates)/total_n. If <10% → proceed (minor impact). If 10-25% → acceptable but note in reporting ('X% ties present, test used tie correction'). If >25% → consider alternatives: Mann-Whitney U (handles ties better), chi-square test if data are actually ordinal categories, or Kolmogorov-Smirnov test. If many ties due to ceiling/floor effects → consider zero-inflated models or different outcome measure.
Why it's wrong
Normal approximation for runs test requires n₁, n₂ ≥ 10. With smaller samples, approximation is inaccurate, leading to incorrect p-values (typically too liberal, inflating Type I error). Standard software implementations use normal approximation, which fails for small n.
The correction
Check sample sizes: if BOTH n₁ ≥ 10 AND n₂ ≥ 10 → normal approximation valid. If either n < 10: (1) Use exact permutation test (simulate all possible group assignments, calculate runs for each, compare observed runs); (2) Use lookup tables for critical values; (3) In R: coin package for exact tests; (4) Or use alternative test like Mann-Whitney U with exact p-value. Report: 'Exact runs test used due to small sample (n₁=X, n₂=X)'.
Why it's wrong
Number of runs provides intuitive interpretation: few runs (< expected) indicates clustering (systematic distribution differences), many runs (> expected) indicates oscillation (unusual but possible with bimodal distributions). Reporting only p-value misses this directional information and practical meaning.
The correction
ALWAYS report: (1) Observed runs, (2) Expected runs, (3) Direction (fewer or more than expected), (4) Interpretation. Example: 'Test significant with 15 runs observed vs. 24 expected, Z=-2.45, p=.014. Fewer runs indicates clustering, suggesting Group A values systematically lower than Group B (distribution difference).' Few runs typically indicates one group systematically higher/lower OR more/less variable.
Why it's wrong
If exploratory analysis (boxplots, descriptive statistics) shows distributions are clearly identical (similar medians, IQRs, ranges, shapes), running runs test is unnecessary and wastes statistical power. Moreover, with large samples, trivial differences become significant, leading to overinterpretation.
The correction
ALWAYS examine data visually first: boxplots, density plots, descriptive statistics. If distributions appear very similar (medians differ <5%, similar spreads and shapes, substantial overlap), consider whether test is needed or if difference is practically meaningful. With large n, statistical significance ≠ practical importance. Report effect sizes and confidence intervals, not just p-values. Focus analysis on questions with practical relevance.
13Academic Lineage

References

Scholarly lineage and citation keys grounding the statistical framework.

We stand on the shoulders of giants. Honor the source of the method.
Academic Lineage
[1]
Wald, A., & Wolfowitz, J. (1940). On a test whether two samples are from the same population. The Annals of Mathematical Statistics, 11(2), 147-162.
Original paper introducing the two-sample runs test for testing distributional equality.
doi: 10.1214/aoms/1177731909
[2]
Gibbons, J. D., & Chakraborti, S. (2011). Nonparametric Statistical Inference (5th ed.). Chapman & Hall/CRC.
Comprehensive textbook covering runs test theory, applications, and comparison with other nonparametric tests. Chapter 8 covers two-sample tests including Wald-Wolfowitz.
[3]
Siegel, S., & Castellan, N. J. (1988). Nonparametric Statistics for the Behavioral Sciences (2nd ed.). McGraw-Hill.
Classic reference explaining runs test logic, assumptions, and interpretation. Pages 144-151 cover two-sample runs test with examples.
[4]
Bradley, J. V. (1968). Distribution-Free Statistical Tests. Prentice-Hall.
Discusses power and efficiency of runs test compared to Mann-Whitney U test. Shows runs test has comparable power for location shifts and superior power for scale/shape differences.
[5]
Conover, W. J. (1999). Practical Nonparametric Statistics (3rd ed.). Wiley.
Practical guide to runs test application, including handling of ties, small samples, and comparison with alternative tests. Chapter 5.8.
[6]
Mood, A. M. (1940). The distribution theory of runs. The Annals of Mathematical Statistics, 11(4), 367-392.
Theoretical foundation for runs test, including derivation of expected runs and variance under null hypothesis.
doi: 10.1214/aoms/1177731825
statminds · Wald-WolfowitzMind reference · v2.2 · updated 2026-01-1715 of 15 sections