R/derandomKnock.R
derandomKnock.Rd
The main function that implements the derandomized knockoffs procedure.
derandomKnock(
X,
y,
type,
M = NULL,
eta = NULL,
seed = 24601,
v = 1,
k = 1,
alpha = 0.05,
knockoff_method = "gaussian",
knockoff_stat = stat.glmnet_coefdiff,
mu = NULL,
Sigma = NULL,
diags = NULL,
pInit = NULL,
Q = NULL,
pEmit = NULL,
thres = 50,
beta = 1
)
a n-by-p matrix of the covariates.
the response vector of length in (can be continuous or binary).
the type of error to control. Options include "pfer" and "kfwer".
an integer specifying the number of knockoff copies computed (default: 30).
a number betweem 0 and 1 indicating the selection frequency (default: 0.5).
an integer specifying the random seed used in the procedure.
a positive numver indicating the PFER target (default: 1). Can be left NULL if using the kfwer error.
a positive integer corresponding to k-FWER.
a number between 0 and 1 indicating the target k-FWER level.
either "gaussian" or "hmm" (default: "gaussian").
Knockoff statistics to used. See knockoff_stat
(default: "stat.glmnet_diff")
a length-p mean vector of X if it follows a Gaussian distribution.
a p-by-p covariance matrix of X if it follows a Gaussian distribution.
a length-p vector, containing the precomputed covariances between the original variables and the knockoffs.
n array of length K, containing the marginal distribution of the states for the first variable, if X is sampled from an HMM.
an array of size (p-1,K,K), containing a list of p-1 transition matrices between the K states of the Markov chain, if X is sampled from an HMM.
an array of size (p,M,K), containing the emission probabilities for each of the M possible emission states, from each of the K hidden states and the p variables, if X is sampled from an HMM.
S the selection set. frequency the selection frequency of the selected variables.
#Generate data
n <- 100; p <- 50; s <- 10;
rho <- 0.5;
Sigma <- toeplitz(rho^(1:p-1))
X <- matrix(rnorm(n*p),n,p)%*%chol(Sigma)
beta <- rep(0,p)
beta[1:s] <- 5/sqrt(n)
y <- X%*%beta+rnorm(n)
# Control PFER at level v=1
res <- derandomKnock(X,y,type = "pfer",v=1, knockoff_method = "gaussian",
mu = rep(0,p),Sigma = Sigma)
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
# Control 1-FWER at level alpha=0.1
res <- derandomKnock(X,y,type = "kfwer", k=1, alpha = 0.1, knockoff_method = "gaussian",
mu = rep(0,p),Sigma = Sigma)
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute
#> Warning: doParallel is not installed. Without parallelization, the statistics will be slower to compute