Performs Aggregated Knockoff analysis by averaging the test statistics across multiple knockoff filters.

agg_Avg(Ws_mat, fdr = 0.05, offset = 0)

Arguments

Ws_mat

A matrix where each row represents the test statistics from a different knockoff filter and each column corresponds to a variable.

fdr

A numeric value specifying the target false discovery rate (FDR) level. Default is \(0.05\).

offset

An integer (0 or 1) specifying the offset in the threshold calculation. Default is \(0\) (liberal control).

Value

A vector shat containing the indices of selected variables after averaging the test statistics and applying the knockoff filter.

See also

Other aggregate: agg_BH(), agg_Freq()

Examples

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_Freq,
                       offset = 1, fdr = 0.1)
#> Loading required package: Matrix
#> Loaded glmnet 4.1-8
res1
#> Call:
#> knockoff.filter(X = X, y = y, Xk = Xk, statistic = stat.glmnet_coefdiff, 
#>     aggregate = agg_Freq, fdr = 0.1, offset = 1)
#> 
#> Selected variables:
#>  [1]  1  2  3  4  5  6  7  8  9 10
#> 
#> 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_Avg(res1$Ws)
#>  [1]  1  2  3  4  5  6  7  8  9 10 15 69