discreteT {DRPT} | R Documentation |
Compute test statistics for the DRPT in discrete settings.
Description
Computes the test statistics introduced in Bordino and Berrett (2025) for settings where the data support is discrete and finite.
Usage
discreteT(NX, NY, r, n, m, type = "V")
Arguments
NX |
A vector of counts for the first sample.
This corresponds to the sequence |
NY |
A vector of counts for the second sample.
This corresponds to the sequence |
r |
A numeric vector of positive values specifying the hypothesised density ratio in the discrete setting. |
n |
The size of the first sample. |
m |
The size of the second sample. |
type |
A character string indicating which test statistic to compute.
One of |
Details
When type = "U"
, the U-statistic (12) is calculated.
When type = "V"
, the V-statistic (11) is computed.
When type = "D"
, the test statistic (56) from Appendix B is returned.
Value
A numeric value representing the computed test statistic.
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/4, 1/4, 1/4, 1/4), replace = TRUE)
Y = sample(0:3, m, prob = c(1/17, 3/17, 3/17, 10/17), replace = TRUE)
r = c(1, 3, 3, 10)
NX = table(X)
NY = table(Y)
discreteT(NX, NY, r, sum(NX), sum(NY), type = "V")
discreteT(NX, NY, r, sum(NX), sum(NY), type = "D")