calculate_w_statistics: Calculate W Statistics for Knockoff Analysis

View source: R/knockoff_filter.R

calculate_w_statisticsR Documentation

Calculate W Statistics for Knockoff Analysis

Description

Computes W statistics by comparing test statistics from original variables with those from their knockoff counterparts. These statistics are used for variable selection with FDR control.

Usage

calculate_w_statistics(t_orig, t_knock, method = "median")

Arguments

t_orig

Vector of test statistics for original variables

t_knock

Vector or list of test statistics for knockoff variables. If a list, should contain M vectors of the same length as t_orig.

method

Method for computing W statistics:

  • "difference": W_j = T_j - max(T_{j,k}) (default)

  • "median": Uses Model-X knockoff median-based statistics

  • "ratio": W_j = T_j / max(T_{j,k})

Value

Vector of W statistics for variable selection

Examples


# Example with difference method
t_orig <- c(5.2, 3.1, 8.7, 2.4, 6.9)
t_knock <- list(
  c(2.1, 4.2, 3.3, 1.8, 2.9),
  c(1.9, 3.8, 4.1, 2.2, 3.1)
)

w_median <- calculate_w_statistics(t_orig, t_knock, method = "median")
w_diff <- calculate_w_statistics(t_orig, t_knock, method = "difference")


CoxMK documentation built on Sept. 9, 2025, 5:24 p.m.