knockoff_filter: Runs knockoff procedure

Description Usage Arguments Details Value References Examples

View source: R/knockoff_filter.R

Description

Runs knockoff procedure for Fixed-X from Barber & Candes (2015).

Usage

1
2
3
4
5
6
7
8
knockoff_filter(
  X,
  y,
  method = c("sdp", "equi"),
  fdr = 0.2,
  plus = TRUE,
  randomize = FALSE
)

Arguments

X

n-by-p design matrix, with n > p.

y

response vector of length n.

method

either "equi" or "sdp" (default: "sdp"). These are two different methods to generate the p-dimensional s vector, which is used to constuct the knockoff variables.

fdr

desired false discovery rate.

plus

True for knockoff+ procedure, false for knockoff procedure.

randomize

If true, U tilde is a random matrix. If false, U tilde is the second half of the matrix Q, where Q is part of the QR decomposition of an nx2p matrix [U\ 0], where X = UDV^T. default is false.

Details

This runs the knockoff filter for a given X matrix and y vector. This controls the false discovery rate at a given level.

Value

A list containing:

X

n-by-p design matrix, rescaled so that ||X_j||^2_2 = 1, and augmented if n < 2p.

Xk

n-by-p matrix of knockoff variables.

y

vector of observed responses (augmented if n < 2p).

W

vector of test statistics.

thresh

threshold for variable selection.

Selected

list of selected variables.

References

Barber and Candes, Controlling the false discovery rate via knockoffs. Ann. Statist. 43 (2015), no. 5, 2055–2085. https://projecteuclid.org/euclid.aos/1438606853

Examples

1
2
3
4
5
6
p <- 50; n <- 100; k <- 5
X <- matrix(stats::rnorm(n*p), nrow = n)
true_covar <- sample(p, k)
beta <- 5 * (1:p %in% true_covar)
y <- X %*% beta + stats::rnorm(n, mean = 0, sd = 1)
results <- knockoff_filter(X, y, 'equi', 0.20, TRUE)

svteichman/prelim.knockoffs documentation built on May 28, 2020, 5:14 p.m.