We introduce PairSwap-ICI, a novel testing algorithm to assess the conditional independence of
-
simulations/
Contains code to reproduce the results in Section 5 of the paper.
Example: Simulation studies for evaluating the power and type-I error control of PairSwap-ICI test. -
real_data_analysis/
Contains code to reproduce the results in Section 6, analyzing real-world dataset (a diabetes example). -
utils/
Contains utility functions required for the implementation of thePairSwap-ICItest.
-
cross_bin_matching
Implements cross-bin matching for a user-specified number of bins$K$ . -
neighbour_matchingImplements neighbour matching, which matches$(Y,Z)$ tuples based on their nearest neighbours in$Z$ -space. -
PairSwapICI_testComputes the$p$ -value for the PairSwap-ICI test, given a dataset of$(X,Y,Z)$ and a matching strategy$M$ (e.g., neighbour or cross-bin matching). -
marg_indep_testTests the marginal independence hypothesis$H_0:X\perp Y$ , given a dataset of$(X,Y,Z)$ .
Clone the repository to get started:
git clone https://github.com/jake-soloff/shape-constrained-CIT.git
cd shape-constrained-CITEnsure you have the required Python libraries installed (e.g., numpy, scipy). Use the following command to install them:
pip install -r requirements.txtBelow are examples for computing PairSwap-ICI test with different matching strategies.
Given PairSwap-ICI test with neighbour matching as follows:
from utils import neighbour_matching, PairSwapICI_test
# Generate or load your data (X, Y, Z)
# X, Y, Z = ...
# Create neighbour matching
M = neighbour_matching(Y, Z)
# Compute the p-value
p = PairSwapICI_test(X, Y, M, nperm)To use cross-bin matching, choose a desired number of bins
from utils import cross_bin_matching, PairSwapICI_test
# Generate or load your data (X, Y, Z)
# X, Y, Z = ...
# Create cross-bin matching with your chosen number of bins K
K = 10 # Example: 10 bins
M = cross_bin_matching(Y, Z, K)
# Compute the p-value
p = PairSwapICI_test(X, Y, M)