Conditional independence tests¶
Two tests are bundled. Both implement the CITest
protocol, so you can also write your own and pass it as ci_test= to
CDANs.
Picking a test¶
| Test | Cost | Assumes | Use when |
|---|---|---|---|
FisherZ |
O(n) | linear, Gaussian | data is approximately linear-Gaussian |
KCITest |
O(n³) | none | dependencies may be nonlinear; surrogate-dependence check |
Pick by name (ci_test="fisherz" or "kci") or by passing an instance for
custom configuration.
CITest ¶
Bases: Protocol
Protocol that every conditional-independence test must implement.
pvalue ¶
Return the p-value of testing X ⊥ Y | Z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
|
required |
y
|
ndarray
|
|
required |
z
|
ndarray | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
float
|
p-value in |
FisherZ ¶
Fisher's Z conditional independence test (partial correlation based).
KCITest ¶
Kernel-based Conditional Independence test (Zhang et al., 2011).
Suitable for both linear and nonlinear, Gaussian and non-Gaussian
relationships. Substantially slower than :class:FisherZ —
O(n^3) per call — so prefer FisherZ for linear-Gaussian
benchmarks and reach for KCI when the residual structure is
plausibly nonlinear.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width_heuristic
|
str
|
How to set the Gaussian kernel bandwidth. |
'empirical'
|
width
|
float | None
|
Manual precision parameter |
None
|
epsilon
|
float
|
Regularization for the conditional residualization step.
|
0.001
|
get_ci_test ¶
Resolve a CI test by name, or return one already given.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | CITest
|
Either a string ( |
required |
**kwargs
|
Forwarded to the test constructor when |
{}
|
Returns:
| Type | Description |
|---|---|
CITest
|
A ready-to-use CI test instance. |