*! version 1.0.0 23dec2025

Title

kuipertest -- Two-sample Kuiper test for equality of distributions

Syntax

kuipertest
varname [if] [in] , "by(varlist:groupvar)"
[,
reps(#)
seed(#)
power(#)]

groupvar must take on
two distinct values. The distribution of varname for the first value of
groupvar is compared with that of the second value.

* "by(varlist:groupvar)" specify a binary variable that identifies the two groups

reps(#) perform # Monte Carlo permutations; default is reps(1000)

seed(#) set random-number seed to #

power(#) specify the exponent for the Kuiper statistic; default is power(1)

* Required

Description

kuipertest performs a two-sample Kuiper permutation test to assess
whether two samples come from the same distribution. The Kuiper statistic measures
the maximum positive and negative deviations between empirical cumulative distribution
functions (ECDFs). The permutation test provides an exact p-value by comparing the
observed statistic to its distribution under random reassignment of group labels.

Options

"by(varlist:groupvar)" is required. It specifies a binary variable
that identifies the two groups.

reps(#) specifies the number of random permutations for the test;
the default is reps(1000).

seed(#) sets the random-number seed for reproducible results.

power(#) specifies the exponent for the Kuiper statistic calculation;
the default is power(1) gives the standard Kuiper statistic.power(>1)
gives more weight to extreme deviations.

Examples

Set-up

. clear

. set obs 20

. gen group = cond(_n < 11,1,2)

. gen x = runiform() in 1/10

. replace x = runiform() * 1.30 if group==2

kuipertest using defaults

. kuipertest x, by(group)

kuipertest with specific seed and more permutations

. kuipertest x, by(group) reps(2000) seed(12345)

change power to squared weighting

. kuipertest x, by(group) reps(2000) seed(12345) power(2)

Stored results

kuipertest stores the following in r():

Scalars

r(stat) observed Kuiper statistic

r(p) permutation p-value

r(reps) number of permutations performed

r(power) power parameter specified

Macros

r(group1) name of group 1

r(group2) name of group 2

References

Kuiper, N. H. 1960.
Tests concerning random points on a circle.
Proceedings of the Koninklijke Nederlandse Akademie van Wetenschappen, Series A.
63: 38-47.

Stephens, M. A. 1970.
Use of the Kolmogorov-Smirnov, Cramer-von Mises and related statistics without extensive tables.
Journal of the Royal Statistical Society, Series B.
32: 115-122.

Citation of wasstest

kuipertest is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2025). KUIPERTEST: Stata module to perform a two-sample Kuiper test for equality of distributions

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

ksmirnov, ranksum, permute, cvmtest (if installed), adtest (if installed), wasstest (if installed), escftest (if installed), distcomp (if installed)