Description Usage Arguments Value Examples
View source: R/knockoff_filters.R
This is a wrapper function that calls knockoff::glmnet.stat_coefdiff. The input data.frames are first converted to design matrices (with the function model.matrix). This means that if the input features contain factor variables then an importance statistic is calculated for each dummy variable as determined by the model.matrix contrasts (defaults to indicator dummy variables with a reference level).
1 | stat_glmnet(X, X_k, y, family, ...)
|
X |
original data.frame (or tibble) with "numeric" and "factor" columns only. The number of columns, ncol(X) needs to be > 2. |
X_k |
knockoff data.frame (or tibble) with "numeric" and "factor" columns only. The dimensions and column classes must match those of the original X. |
y |
response vector with |
family |
should be "gaussian" if y is numeric, but "binomial" if y is a binary factor variable. |
... |
additional parameters passed to knockoff::stat.glmnet_coefdiff |
a vector of importance statistics W of length equal to number of columns of the model.matrix of X.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(seqknockoff)
set.seed(1)
# Simulate 10 Gaussian covariate predictors:
X <- generate_X(n=1000, p=10, p_b=0, cov_type="cov_equi", rho=0.5)
# Calculate the knockoff copy of X:
X_k <- knockoffs(X)
# Simulate response from model y = X%*%beta + epsilon, where epsilon ~ N(0,1) with
# first 5 beta-coefficients = 8 (all other zero).
y <- generate_y(X, p_nn=5, a=8)
W <- stat_glmnet(X=X, X_k=X_k, y=y, family="gaussian", nfolds=5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.