Overview

The knockoff package supports two styles of knockoff variables, equicorrelated knockoffs (the default) and semidefinite programming (SDP) knockoffs. Though more computationally expensive, the SDP knockoffs are statistically superior by having higher power. Unfortunately, the R programming environment has poor support for semidefinite programming. To create SDP knockoffs, this package relies on the Python library CVXPY.

The knockoff package will automatically invoke the Python interpreter to create SDP knockoffs provided that (1) you have a Python installation with CVXPY and (2) R can find your Python interpreter. Thus, to use SDP knockoffs you should:

  1. Install Python and CVXPY

On Unix platforms this is usually straightforward. If you don’t have a Python installation, follow the instructions included with CVXPY. If you already have Python (along with NumPy and SciPy), running pip install cvxpy will likely work.

On Windows, matters are more complicated. You can attempt the instructions for Windows included with CVXPY. Alternatively, you can skip the compilation process by using pre-compiled binaries, according to the alternative installation instructions provided below.

  1. Verify that R can find the Python interpretator

Launch on your R environment. On Unix, run

system('which python')

or on Windows, run

system('where python')

You should see the path to your Python installation. If not, adjust your PATH environment variable appropriately.

Installation instructions for Windows

These alternative instructions for MS Windows use pre-compiled binaries.

  1. Download and install Python 2.7

Note: Even if you are running 64-bit Windows, make sure to use the 32-bit Python binaries. Due to a bug in cvxopt, CVXPY is effectively broken on 64-bit Windows.

  1. Prepend the string

    C:\Python27\;C:\Python27\Scripts\

    to your PATH environment variable

  2. Download and install the following binaries created by Christoph Gohlke:
  1. Open the Windows command prompt (not the Python interpreter) and run the following commands:

    pip install toolz
    pip install cvxpy --no-deps

You should now have a working CVXPY installation.

Note: At the time of this writing, there are no pre-compiled binaries for SCS, an optional dependency of CVXPY. If SCS is not installed, CVXPY will emit warnings but will nonetheless function correctly. However, CVXPY 0.2.15 and older contain a bug that causes the warning logic to fail. If you encounter this problem, open the file

C:\Python27\Lib\site-packages\cvxpy\problems\solvers\scs_intf.py

and add the line import warnings as indicated here.