Slow delete-one jackknife for rank-weighted L-stat rules (fixed ranks)
Source:R/jackknife-rank-slow.R
jackknife_slow_rank.RdA reference implementation that recomputes aggregates per deletion using the provided neighbor ranks. This does not recompute ranks after deletion (useful as a correctness oracle and for testing).
Arguments
- ranks
Integer matrix (T x (s+1)): for each target
t,ranks[t, k]gives the positive 1-based index of the k-th neighbor, fork = 1, ..., s+1. (Must excludetitself if targets are a subset of reference.)- a
Finite numeric length-
svector of L-stat coefficients \((a_1,\dots,a_s)\).- phi
Either a finite numeric matrix (n_ref x q) with row
jequal to \(\phi(j)\), or a functionphi(j, t)returning a finite length-qnumeric vector.- normalize
Scalar logical; if
TRUE(default) divide aggregates bysum(a).
Value
A list with:
- theta0
numeric length-
qbaseline aggregate- theta_loo
numeric matrix (n_ref x q) of delete-one aggregates
- info
list with fields
s,T,q,normalize
Details
Like jackknife_fast_rank(), this helper targets compact-support
finite-rank L-stat rules. It is not the internal engine used by the
user-level exact DNN wrappers, which instead update the full rank matrix
under deletion and reevaluate the DNN rank-weight rule.
Works with:
phias a numeric matrix (n_ref x q): rowjequals \(\phi(j)\).phias a functionfunction(j, t)that returns a length-qnumeric, allowing target-dependent contributions.
Examples
set.seed(1)
n <- 20
p <- 3
s <- 4
X <- matrix(rnorm(n * p), n, p)
# toy ranks: nearest-neighbor indices precomputed elsewhere (T x (s+1))
# here we fake something deterministic just for the example
ranks <- cbind(matrix(rep(1:s, each = n), n, s), s + 1L)
y <- rnorm(n)
a <- rep(1, s)
out <- jackknife_slow_rank(ranks, a, cbind(y))
str(out)
#> List of 3
#> $ theta0 : num 0.77
#> $ theta_loo: num [1:20, 1] -0.0162 0.594 0.4118 0.5772 0.77 ...
#> $ info :List of 4
#> ..$ s : int 4
#> ..$ T : int 20
#> ..$ q : int 1
#> ..$ normalize: logi TRUE