Description Usage Arguments Value Examples
Refitting a path of selected variables from the cheapknockoff filter and compute prediction on the newdata
1 |
path |
A path of selected variables set |
x |
A |
y |
A |
newdata |
A new data set of features that the predictions are computed |
family |
The conditional distribution of y given X. See the family option for |
a list consisting the refitted model and the corresponding prediction for each model on the path returned by generate_path
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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)
# yield the path of selected variables
path <- cheapknockoff::generate_path(kappa = stat$kappa, tau = stat$tau)
# refit and compute predictions on the original data
refit_output <- refit(path, x, y, x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.