Knockoff
’s FDR ControlLast updated: 2018-04-03
Code version: 5bce84a
library(knockoff)
n <- 1e4
p <- 4
Sigma <- matrix(c(1, 0.99, 0, 0, 0.99, 1, 0, 0, 0, 0, 1, 0.01, 0, 0, 0.01, 1), byrow = TRUE, 4, 4)
beta <- c(5, 0, 5, 0) / sqrt(n)
W <- list()
for (i in 1 : 1000) {
X1 <- rnorm(n)
X2 <- 0.99 * X1 + sqrt(1 - 0.99^2) * rnorm(n)
X3 <- rnorm(n)
X4 <- 0.01 * X3 + sqrt(1 - 0.01^2) * rnorm(n)
X <- cbind(X1, X2, X3, X4)
Xk <- knockoff::create.gaussian(X, mu = rep(0, 4), Sigma = Sigma, method = "sdp")
y <- X %*% beta + rnorm(n)
W[[i]] <- knockoff::stat.glmnet_coefdiff(X, Xk, y)
}
sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.4
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.3 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
[5] tools_3.4.3 htmltools_0.3.6 yaml_2.1.18 Rcpp_0.12.14
[9] stringi_1.1.6 rmarkdown_1.9 knitr_1.20 git2r_0.21.0
[13] stringr_1.3.0 digest_0.6.15 evaluate_0.10.1
This R Markdown site was created with workflowr