`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
)
```

- X
a n-by-p matrix of the covariates.

- y
the response vector of length in (can be continuous or binary).

- type
the type of error to control. Options include "pfer" and "kfwer".

- M
an integer specifying the number of knockoff copies computed (default: 30).

- eta
a number betweem 0 and 1 indicating the selection frequency (default: 0.5).

- seed
an integer specifying the random seed used in the procedure.

- v
a positive numver indicating the PFER target (default: 1). Can be left NULL if using the kfwer error.

- k
a positive integer corresponding to k-FWER.

- alpha
a number between 0 and 1 indicating the target k-FWER level.

- knockoff_method
either "gaussian" or "hmm" (default: "gaussian").

- knockoff_stat
Knockoff statistics to used. See

`knockoff_stat`

(default: "stat.glmnet_diff")- mu
a length-p mean vector of X if it follows a Gaussian distribution.

- Sigma
a p-by-p covariance matrix of X if it follows a Gaussian distribution.

- diags
a length-p vector, containing the precomputed covariances between the original variables and the knockoffs.

- pInit
n array of length K, containing the marginal distribution of the states for the first variable, if X is sampled from an HMM.

- Q
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.

- pEmit
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
```