18. FFCI (Fourier Features Conditional Independence)

Command: ffci-test
Kind: Independence test

The description below is Tetrad’s own, shown in the interface when you select this method. It is reproduced here so that the method is documented; it has not yet been edited for the manual, and it has no “when to use” guidance of the kind the hand-written pages carry.

A approximate kernel-based conditional independence (CI) test for datasets containing any mix of continuous and discrete variables, implementing the Feature-Function CI (FF-CI) framework. Overview: FF-CI tests whether two variables X and Y are conditionally independent given a set Z, using a nonparametric kernel approach. Variables are mapped into a finite-dimensional feature space, cross-covariances are computed there, and a quadratic-form statistic is evaluated against its null distribution to produce a p-value. Continuous-only datasets If the dataset contains no discrete variables, all CI queries are delegated transparently to FfCiContinuous, and this class behaves identically to that implementation given the same hyperparameter settings. Mixed datasets: When discrete variables are present, each variable type is featurized separately: Continuous variables — mapped via Random Fourier Features (RFF) or Orthogonal Random Features (ORF), approximating a Gaussian kernel. The kernel bandwidth is estimated from the data using the median pairwise distance heuristic. Discrete variables — mapped via a categorical feature map. When catRho == 0 (the default), this reduces to standard one-hot encoding. When catRho > 0, a PSD feature map is used corresponding to the kernel with diagonal entries 1 and off-diagonal entries catRho, constructed via Cholesky factorization. The continuous and discrete feature blocks are horizontally stacked to form a joint feature representation for each variable (or block of variables). Conditional testing: Conditioning on Z is handled by ridge residualization in feature space: the feature matrices for X and Y are each regressed on the feature matrix for Z using a ridge penalty (lambda), and the residuals are used to compute the test statistic. This mirrors the approach used in FfCiContinuous. Test statistic and p-value: The test statistic is n * ||Cov(fX, fY)||_F^2, where fX and fY are the (possibly residualized) feature matrices. Its null distribution is approximated as a weighted sum of chi-squared(1) variables, with weights given by the positive eigenvalues of the sample Khatri-Rao covariance matrix. The p-value can be obtained via one of four methods selectable through setApproximation: GAMMA — Satterthwaite/moment-matching gamma approximation (default) SADDLEPOINT — Lugannani-Rice saddlepoint approximation DAVIES_IMHOF — Davies/Imhof numerical integration PERMUTATION — permutation test (exact but slow) Caching: Feature matrices and kernel bandwidths are cached by a key that encodes the variable names, active row set, hyperparameters, and a dataVersion counter. Call bumpDataVersion() after any in-place modification of the dataset (e.g., resimulation) to invalidate stale cached values. Key references: Zhang et al. (2012). “Kernel-based conditional independence test and application in causal discovery.” UAI. Rahimi & Recht (2007). “Random features for large-scale kernel machines.” NeurIPS. Yu et al. (2016). “Orthogonal random features.” NeurIPS.