filter_gz: Multiple knockoff filter by Gimenez & Zou (2018)

Description Usage Arguments Value Examples

View source: R/gz.R

Description

This function implements the stable m-knockoff filter by Gimenez & Zou (2018) given the test statistics (kappa, tau)

Usage

1
filter_gz(kappa, tau, fdr = 0.2, n_knockoff)

Arguments

kappa

A p vector of test statistics, with kappa_i = 1 indicating the original variable winning

tau

A p vector of test statistics, showing the manitude/importance of the variable

fdr

The pre-specified upper bound level of controlled FDR.

n_knockoff

number of knockoffs constructed

Value

The selected variable and their corresponding scores

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(cheapknockoff)
set.seed(123)
n <- 100
p <- 30
x <- matrix(data = rnorm(n * p), nrow = n, ncol = p)
y <- x[, 1] - 2 * x[, 2] + rnorm(n)
omega <- c(2, 9, sample(seq(2, 9), size = 28, replace = TRUE))
# construct multiple knockoffs
X_k <- multiple_knockoff_Gaussian(X = x, mu = rep(0, p), Sigma = diag(1, p), omega = omega)
# compute knockoff statistics
stat <- stat_glmnet_coef(X = x, X_k = X_k, y = y, omega = omega)
# run gz filter
gz_output <- filter_gz(kappa = stat$kappa, tau = stat$tau, fdr = 0.2, n_knockoff = max(omega))

hugogogo/cheapknockoff documentation built on Sept. 15, 2021, 1:06 p.m.