discrete.DRPT {DRPT}R Documentation

A function implementing the discrete version of the DRPT for discrete data with finite support.

Description

A function that implements the discrete version of the DRPT for discrete data with finite support as defined in Section 2.1 in Bordino and Berrett (2025).

Usage

discrete.DRPT(X, Y, r, H = 99, type = "V")

Arguments

X

A numeric vector containing the first sample.

Y

A numeric vector containing the second sample.

r

A numeric vector of positive values specifying the hypothesised density ratio in the discrete setting.

H

An integer specifying the number of permutations to use. Defaults to 99.

type

A character string indicating the test statistic to use. See the Details section for more information. Defaults to "V".

Details

Counts for the permuted samples are drawn using rMFNCHypergeo from the package BiasedUrn. When type="U" the test statistic is the U-statistic (12); when type="V" the test statistic is the V-statistic (11); setting type="D" gives the test statistic (56) in Appendix B of the paper.

Value

The p-value of the DRPT as defined in (2) in Bordino and Berrett (2025).

References

Bordino A, Berrett TB (2025). “Density Ratio Permutation Tests with connections to distributional shifts and conditional two-sample testing.” arXiv:2505.24529, https://arxiv.org/abs/2505.24529.

Examples

n = 100; m = n
X = sample(0:3, n, prob = c(1/8, 1/8, 3/8, 3/8), replace = TRUE)
Y = sample(0:3, m, prob = c(1/43, 3/43, 16/43, 23/43), replace = TRUE)
r = c(1, 3, 3, 10)

discrete.DRPT(X,Y,r,H=19)
discrete.DRPT(X,Y,r, type = "U", H=19)
discrete.DRPT(X,Y,r, type = "D", H=19)

[Package DRPT version 1.1 Index]