Skip to content

ADescribe · Guide test 267

Rao circular homogeneity tests

Provide large sample comparisons of polar vectors and dispersion across angular populations.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

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

20
20
20
70
50
0.050

Your data

Drag a point or use ↑/↓ to change it
0°90°180°270°Group 1: n = 20, θ̄ = 42°, R̄ = 0.72Group 2: n = 20, θ̄ = 61°, R̄ = 0.68

Sectors 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

Q = 0.95
  1. The reference: how Q varies across samples when H₀ is true (χ² limit with k − 1 df).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .330).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Q=∑g(ag−aˉw)2vg,ag=SˉgCˉg,aˉw=∑gag/vg∑g1/vgQ=\sum_g\frac{(a_g-\bar a_w)^2}{v_g},\qquad a_g=\frac{\bar S_g}{\bar C_g},\quad \bar a_w=\frac{\sum_ga_g/v_g}{\sum_g1/v_g}

With your numbers

Q=0.95 (polar),Qdisp=0.07, p=0.79 (dispersion)Q = 0.95\ \text{(polar)},\quad Q_{disp} = 0.07,\ p = 0.79\ \text{(dispersion)}
aga_g
the tangent of group g's mean direction
vgv_g
its large-sample variance by the delta method
QdispQ_{disp}
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 H0.

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

Q=∑g(ag−aˉw)2vgaˉw=∑gag/vg∑g1/vg\begin{gathered}Q=\sum_g\frac{(a_g-\bar a_w)^2}{v_g}\\[5pt]\bar a_w=\frac{\sum_ga_g/v_g}{\sum_g1/v_g}\end{gathered}

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.

Python · invokes R

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()
R

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.0883

Sources

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.