varUn: Compute the unbiased variance estimator of a general 2-sample...

View source: R/varUn.R

varUnR Documentation

Compute the unbiased variance estimator of a general 2-sample U-statistic

Description

Compute the unbiased variance estimator of a general 2-sample U-statistic

Usage

varUn(sample1, sample2, k1, k2, phi, B = Inf, u_stat = NULL)

Arguments

sample1

The first sample.

sample2

The second sample.

k1

The number of observations drawn from sample 1 to compute the kernel function phi.

k2

The number of observations drawn from sample 2 to compute the kernel function phi.

phi

The kernel function of the U-statistic

B

The number of random partitions in the partition-resampling realization.

u_stat

The value of the U-statistic. This is an optional argument. If provided, Q(k) is computed as the square of the inputted u_stat value. Otherwise, the complete U-statistic is computed based on the input kernel function phi.

Value

The variance of a 2-sample U-statistic

References

Q. Wang and A. Guo (2020). An efficient variance estimator of AUC with applications to binary classification. Statistics in Medicine 39 (28): 4281-4300. DOI: 10.1002/sim.8725.

Examples

library(VGAM)
N <- 500
true.rho <- 0.7
data.mat <- rbinorm(N, cov12 =  true.rho)  # Bivariate normal
x <- data.mat[, 1]
y <- data.mat[, 2]
u_stat_value <- kendall.tau(x,y,exact=TRUE) # Exact value of Kendall Tau statistic
# Phi function for the Kendall Tau statistic
kernel <- function (s1, s2){
result <- 0
ind <- 0
if (s1[1] < s2[1] && s1[2] < s2[2]){
ind <- 1
} else if (s1[1] > s2[1] && s1[2] > s2[2]) {
ind <- 1
}
return (2*(ind)-1)
}
varUn(x, y, 2, 2, kernel, 10^3, u_stat_value)


fmoyaj/aucvar documentation built on Nov. 28, 2023, 10:50 p.m.