Learn R Programming

DRPT (version 1.1)

discreteT: Compute test statistics for the DRPT in discrete settings.

Description

Computes the test statistics introduced in BB2025DRPT;textualDRPT for settings where the data support is discrete and finite.

Usage

discreteT(NX, NY, r, n, m, type = "V")

Value

A numeric value representing the computed test statistic.

Arguments

NX

A vector of counts for the first sample. This corresponds to the sequence \(\mathrm{tot}_j - N_{Y,j}^p\) with \(p = \mathrm{id}\), i.e. the identity permutation, as introduced in Section 2.1 of BB2025DRPT;textualDRPT.

NY

A vector of counts for the second sample. This corresponds to the sequence \(N_{Y,j}^p\) with \(p = \mathrm{id}\), i.e. the identity permutation, as introduced in Section 2.1 of BB2025DRPT;textualDRPT.

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 "U", "V", or "D". See the Details section for more information. Defaults to "V".

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.

References

BB2025DRPTDRPT

Examples

Run this code
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")

Run the code above in your browser using DataLab