DRPT: A function implementing the Density Ratio Permutation Test...

View source: R/DRPT.R

DRPTR Documentation

A function implementing the Density Ratio Permutation Test based on an estimate of the shifted-MMD.

Description

A function that implements the DRPT based on the U-statistic (12) defined in \insertCiteBB2025DRPT;textualDRPT. An estimator of the shifted-MMD with kernel k(\cdot, \cdot) as defined in Section 3.2 of the paper is computed using the function shiftedMMD, which is provided in the package.

Usage

DRPT(X, Y, r, kernel, H = 99, S = 50)

Arguments

X

A numeric vector containing the first sample.

Y

A numeric vector containing the second sample.

r

A function specifying the hypothesised density ratio.

kernel

A function defining the kernel to be used for the U-statistic.

H

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

S

An integer specifying the number of steps for the Markov-Chain defined in Algorithm 2 in \insertCiteBB2025DRPT;textualDRPT. Defaults to 50.

Value

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

References

\insertRef

BB2025DRPTDRPT

Examples

n = 50; m = 50; d = 2
r = function(x,y) {
  return(4*x*y)
   }

gaussian.kernel = function(x, y, lambda = 1){
     return(lambda^(-d) * exp(-sum(((x - y) ^ 2) / (lambda ^ 2))))
     }

X = as.matrix(cbind(runif(n, 0, 1), runif(n, 0, 1)))
Y = as.matrix(cbind(rbeta(m, 0.5, 0.3), rbeta(m, 0.5, 0.4)))

DRPT(X,Y, r, gaussian.kernel, H=19, S=10)
DRPT(X,Y, r, gaussian.kernel, H=9)

DRPT documentation built on Aug. 8, 2025, 7:40 p.m.

Related to DRPT in DRPT...