ADescribe · Guide test 267
Rao circular homogeneity tests
Provide large sample comparisons of polar vectors and dispersion across angular populations.
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 = Rao (polar vectors and dispersions).
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 · Rao homogeneity test
Your data
Drag a point or use ↑/↓ to change itSectors are area-proportional counts; the arrows point to each mean direction, with length R̄ (0: no preferred direction, 1: all identical).
If H₀ were true
- The reference: how Q varies across samples when H₀ is true (χ² limit with k − 1 df).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .330).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- the tangent of group g's mean direction
- its large-sample variance by the delta method
- Rao's companion test of equal dispersions, from R̄²
The verdict
Q(1) = 0.95, p = .330
p > α = .050: compatible with H₀
Large-sample tests: with small groups or mean directions near ±90° the polar vector is unstable, so prefer Watson–Williams or a permutation p.
- Statistic
- 0.950
- p-value
- 0.3298
Rao homogeneity test on Group 1 (°): n = 20; Group 2 (°): n = 20: Q(1) = 0.95, p = .330. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: groups share polar direction, or share resultant dispersion; these are separate Rao tests.
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. Large group samples and nondegenerate resultant/covariance estimates; the tangent-based direction form requires a suitable common angular branch.
Formula
Parameters and notation
Let cg=mean cosθ,sg=mean sinθ and Σg be covariance of (cosθ,sinθ). For direction use ag=sg/cg with gradient (−sg/cg²,1/cg); for dispersion use ag=cg²+sg² with gradient (2cg,2sg). In each case vg=gradientᵀΣg gradient/ng.
Structure of the method
Rao homogeneity procedures compute sample trigonometric moments, derive separate direction/polar and dispersion summaries, estimate their variances, and compare groups with large-sample quadratic statistics. The package returns distinct mean and dispersion results; they should not be collapsed into one unqualified omnibus p value.
Estimated and nuisance parameters
Estimated nuisance quantities include group means of sine/cosine and covariance matrices of those components. The direction and resultant-length transformations have different gradients. A tangent representation requires an admissible common branch and must not identify antipodal directions merely because their tangents coincide.
Settings and design choices
Choose which scientific hypothesis is primary and whether both tests will be reported. If both are confirmatory, define the multiplicity policy. Angular conversion, any common rotation and handling of near-zero resultant lengths should be documented before applying asymptotic reference distributions.
Fitting and adaptation
No neural fitting is involved. Recalculate moment/covariance estimates for each new dataset. When regularity is doubtful, use a separately justified circular method or simulation study rather than forcing a singular variance estimate into a chi-square calculation. The rao.test alpha option changes reporting, not the estimated distribution.
Sensitivity and robustness
Small or highly diffuse groups make delta-method approximations fragile. Near-zero cosine moments destabilize tangent-based direction formulas, while near-zero resultant length makes mean direction scientifically weak. Inspect circular plots and report both uncertainty and group sizes; a small p value does not validate the chosen angular branch.
How to use and calibrate
Use χ²k−1 asymptotically for each hypothesis; address multiplicity if both are used.
Example application
Compare angular direction and concentration summaries across several groups.
Interpretation and pitfalls
Watch out
Direction is unstable when resultant length is near zero; tangent singularities require rotation or another circular method.
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::rao.test(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::rao.test(a,b))
Output
Rao's Tests for Homogeneity
Test for Equality of Polar Vectors:
Test Statistic = 7.56
Degrees of Freedom = 1
P-value of test = 0.006
Test for Equality of Dispersions:
Test Statistic = 2.9046
Degrees of Freedom = 1
P-value of test = 0.0883Sources
- circular — circular · rao.testAuthor documentation/source reviewed: circular 0.5-2.search.r-project.org
- rao.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 267, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT267.