Learn R Programming

CoxMK (version 0.1.1)

calculate_w_statistics: 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")

Value

Vector of W statistics for variable selection

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})

Examples

Run this code
# \donttest{
# 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")
# }

Run the code above in your browser using DataLab