agg_Freq.RdPerforms Aggregated Knockoff analysis by selecting variables based on their selection frequency across multiple knockoff filters.
agg_Freq(Ws_mat, fdr = 0.05, offset = 0, tau = 0.5)A matrix where each row represents the test statistics from a different knockoff filter, and each column corresponds to a variable.
A numeric value specifying the target false discovery rate (FDR) level. Default is \(0.05\).
An integer (0 or 1) specifying the offset in the threshold calculation. Default is \(0\) (liberal control).
A numeric value indicating the selection frequency threshold for variable inclusion. Default is \(0.5\).
A vector shat containing the indices of selected variables after applying selection frequency and the knockoff filter.
Ren, Z., Wei, Y., & Candès, E. (2023). Derandomizing knockoffs. Journal of the American Statistical Association, 118(542), 948-958.
set.seed(2024)
p = 100; n = 80
X = generate_X(n=80,p=100)
y <- generate_y(X, p_nn=10, a=3)
Xk = create.shrink_Gaussian(X = X, n_ko = 10)
res1 = knockoff.filter(X, y, Xk, statistic = stat.glmnet_coefdiff,
                       aggregate = agg_BH,
                       offset = 1, fdr = 0.1)
res1
#> Call:
#> knockoff.filter(X = X, y = y, Xk = Xk, statistic = stat.glmnet_coefdiff, 
#>     aggregate = agg_BH, fdr = 0.1, offset = 1)
#> 
#> Selected variables:
#> integer(0)
#> 
#> Frequency of selected variables from 10 knockoff copys:
#>   [1] 10 10 10 10 10  8 10 10  9 10  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
#>  [26]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
#>  [51]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
#>  [76]  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
agg_Freq(res1$Ws)
#>  [1]  1  2  3  4  5  6  7  8  9 10