Description Usage Arguments Value Examples
View source: R/generate_statistics.R
This function computes the knockoff statistics based on the absolute value of the coefficient estimate from glmnet.
1 2 3 4 5 6 7 8 9  | stat_glmnet_coef(
  X,
  X_k,
  y,
  omega,
  family = "gaussian",
  nlam = 500,
  lam_min_ratio = 5e-04
)
 | 
X | 
 A   | 
X_k | 
 A   | 
y | 
 A   | 
omega | 
 A   | 
family | 
 The conditional distribution of y given X. See the family option for   | 
nlam | 
 Number of tuning parameter lambda used in fitting the lasso. Default to be 500.  | 
lam_min_ratio | 
 The ratio of the minimum and the maximum value of lambda in constructing the tuning parameters. Default to be   | 
An list of three components:
kappathe vector of indices of winner for each variable competing with its multiple knockoff counterparts. kappa[j] = 1 indicates that the original variable is beating all of its knockoff counterparts, and kappa[j] not equal to 1 means otherwise.
taua vector of scores determining the order for which we consider to include variables into the model.
score_totalthe matrix containing the original 'glmnet' coefficient estimates for each variable and its knockoff counterparts. For example, score_total[1:omega[j], j] is the coefficients estimates for the j-th variables and its omega_j - 1 knockoff counterparts.
1 2 3 4 5 6 7 8 9 10 11  | 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 <- cheapknockoff::stat_glmnet_coef(X = x, X_k = X_k, y = y, omega = omega)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.