Learn R Programming

DRPT (version 1.1)

discrete.DRPT: 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 BB2025DRPT;textualDRPT.

Usage

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

Value

The p-value of the DRPT as defined in (2) in BB2025DRPT;textualDRPT.

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.

References

BB2025DRPTDRPT

Examples

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

Run the code above in your browser using DataLab