This vignette illustrates the basic usage of the `knockoff`

package with Fixed-X knockoffs. In this scenario we make no assumptions on the distribution of the predictors (which can be considered fixed), but we assume a homoscedastic linear regression model for the response. In this scenario, knockoffs only control the FDR if used in combination with statistics that satisfy the “sufficiency” property. In particular, the default statistics based on the cross-validated lasso are not valid.

For simplicity, we will use synthetic data constructed from a linear model such that the response only depends on a small fraction of the variables.

`set.seed(1234)`

```
# Problem parameters
= 500 # number of observations
n = 100 # number of variables
p = 30 # number of variables with nonzero coefficients
k = 4.5 # signal amplitude (for noise level = 1)
amplitude
# Generate the variables from a multivariate normal distribution
= rep(0,p)
mu = 0.25
rho = toeplitz(rho^(0:(p-1)))
Sigma = matrix(rnorm(n*p),n) %*% chol(Sigma)
X
# Generate the response from a linear model
= sample(p, k)
nonzero = amplitude * (1:p %in% nonzero) / sqrt(n)
beta = function(X) X %*% beta + rnorm(n)
y.sample = y.sample(X) y
```

In order to create fixed-design knockoffs, we call `knockoff.filter`

with the parameter `statistic`

equal to `stat.glmnet_lambdadiff`

. Moreover, since not all statistics are valid with fixed-design knockoffs, we use `stat.glmnet_lambdasmax`

instead of the default one (which is based on cross-validation).

```
library(knockoff)
= knockoff.filter(X, y, knockoffs = create.fixed, statistic = stat.glmnet_lambdasmax) result
```

We can display the results with

`print(result)`

```
## Call:
## knockoff.filter(X = X, y = y, knockoffs = create.fixed, statistic = stat.glmnet_lambdasmax)
##
## Selected variables:
## [1] 3 5 8 10 14 18 19 21 27 28 30 31 32 33 36 38 39 40 43 44 46 48 49 52 54
## [26] 55 57 64 67 76 80 83 94 96
```

The default value for the target false discovery rate is 0.1. In this experiment the false discovery proportion is

```
= function(selected) sum(beta[selected] == 0) / max(1, length(selected))
fdp fdp(result$selected)
```

`## [1] 0.1176471`

If you want to see some basic usage of the knockoff filter, see the introductory vignette. If you want to look inside the knockoff filter, see the advanced vignette.