ADescribe · Guide test 266
Wallraff test
Compares angular distances from reference directions, often to assess differences in angular dispersion.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Comparing directions between groups (Watson–Williams, U², Wheeler, Wallraff, Rao) — Do two or more groups differ in their typical direction, their spread, or the whole distribution of directions?
In Comparing directions between groups (Watson–Williams, U², Wheeler, Wallraff, Rao), choose Test = Wallraff (angular spread).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Wallraff test
Wallraff asks whether the two groups scatter equally around their own means.
Your data
Drag a direction around the dialSectors are area-proportional counts; the arrows point to each mean direction, with length R̄ (0: no preferred direction, 1: all identical). Wallraff ranks every direction's distance to its own group's mean.
If H₀ were true
- The reference: how H varies across samples when H₀ is true (χ² limit of the Kruskal–Wallis H).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .021).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- angular distance of each direction from its own group's mean direction
- mean rank of a group's distances (Kruskal–Wallis, tie-corrected)
The verdict
H(1) = 5.29, p = .021
p ≤ α = .050: reject H₀
A test of dispersion, not of mean direction: groups pointing different ways but equally scattered are compatible with H0.
- Statistic
- 5.287
- p-value
- 0.0215
Wallraff test on Group 1 (°): n = 20; Group 2 (°): n = 20: H(1) = 5.29, p = .021. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: groups have equal distributions of angular distance from stated reference directions.
Assumptions
Independent angular observations with a clear radians/degrees convention and orientation. The usual null uses a full circular domain; axial data require an appropriate doubling transformation or axial model. Reference angles must be specified or estimated using the method’s convention.
Formula
Parameters and notation
μg is a prespecified reference or group circular mean; R ranks distances di∈[0,π]. Apply tie correction.
Structure of the method
Transform every angle to its shortest angular distance from the designated group reference, then compare the resulting linear distances with a Kruskal–Wallis rank statistic and its tie correction. The transformation changes the question from equality of complete circular distributions to equality of distance distributions.
Estimated and nuisance parameters
Reference angles are fixed inputs when externally specified; otherwise group circular means are estimated nuisance quantities. Pooled distance ranks and their group sums are computed from the data. No concentration parameter or neural representation is learned.
Settings and design choices
Specify whether one common reference, several external references or fitted group means are intended. In circular::wallraff.test, ref=NULL uses group means; a supplied reference vector follows group ordering and may be recycled. Record that order explicitly to prevent a silent change of estimand.
Fitting and adaptation
Adaptation means choosing a defensible reference convention and calibration, not optimizing references to maximize separation. Any custom resampling that re-estimates centers should repeat the entire centering/ranking procedure and justify its null exchangeability; simple permutations are not automatically exact for every composite dispersion null.
Sensitivity and robustness
Circular means become unstable for diffuse or antipodal samples. Similar mean directions do not imply equal dispersion, and distance equality discards angular-side information. Check ties caused by rounding, uneven groups and within-subject dependence; report the reference angles alongside the statistic and p value.
How to use and calibrate
Use the Wallraff rank comparison, commonly Kruskal–Wallis χ²k−1; resampling with estimated centers should recompute centers.
Example application
Compare directional dispersion around each group’s mean orientation.
Interpretation and pitfalls
Watch out
With different fixed reference directions this tests angular distances, not necessarily dispersion about population means.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Two independent circular samples. Watson–Williams is a common-concentration von Mises mean-direction test; rank/distributional alternatives answer different questions. Synthetic kappa=4 provides a reasonably concentrated example.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: circular
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
a<-circular::rvonmises(40,circular::circular(0),kappa=4);b<-circular::rvonmises(40,circular::circular(.3),kappa=4)
print(circular::wallraff.test(list(a,b)))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs circular
set.seed(2026)
a<-circular::rvonmises(40,circular::circular(0),kappa=4);b<-circular::rvonmises(40,circular::circular(.3),kappa=4)
print(circular::wallraff.test(list(a,b)))
Output
Wallraff rank sum test of angular distance data: 1 and 2 Kruskal-Wallis chi-squared = 3.169, df = 1, p-value = 0.07505
Sources
- circular — circular · wallraff.testAuthor documentation/source reviewed: circular 0.5-2.search.r-project.org
- wallraff.testsearch.r-project.org
- circularsearch.r-project.org
- rvonmisessearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 266, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT266.