citk.tests.partial_correlation_tests

Partial-correlation CI tests (survey family): FisherZ, Spearman.

Both tests use a self-contained Schur-complement partial correlation plus Fisher-Z transform — no causal-learn dependency. Each instance satisfies the structural cbcd.CITest Protocol, so it can be passed directly into cbcd.pc(data, ci_test=FisherZ(data)).

Classes

FisherZ

Fisher-Z partial correlation test (continuous, Gaussian).

Spearman

Spearman partial correlation: Fisher-Z applied to ranked data.

Module Contents

class citk.tests.partial_correlation_tests.FisherZ(data: numpy.ndarray, **kwargs: Any)[source]

Bases: citk.tests.base.CITKTest

Fisher-Z partial correlation test (continuous, Gaussian).

Native implementation; no causal-learn dependency. Compatible with cbcd via the structural cbcd.CITest Protocol — pass an instance directly to cbcd.pc(data, ci_test=FisherZ(data)).

Initialise the test and (optionally) load a JSON p-value cache.

Parameters:
  • data – Sample matrix in shape (n, p).

  • cache_path – Optional path to a JSON cache file used to memoise p-values across calls. The cache is keyed by (data_hash, method_name, parameters_hash) and stamped with format_version so v0.1.0 caches can be detected and invalidated by future releases.

Raises:

TypeError – If kwargs contains keys outside cls.accepted_kwargs and cls._protocol_kwargs.

details(X: int, Y: int, condition_set: list[int] | None = None, **kwargs: Any) citk.tests.base.CITKResult[source]

Return a structured CITKResult for one CI query.

Default implementation calls __call__() and wraps the float p-value in a CITKResult. Subclasses with richer diagnostics (test statistic, df, n_effective) can override to populate those fields. cbcd’s algorithms only read .p_value from cached results, so this default is sufficient for cbcd interop.

supported_dtypes
class citk.tests.partial_correlation_tests.Spearman(data: numpy.ndarray, **kwargs: Any)[source]

Bases: citk.tests.base.CITKTest

Spearman partial correlation: Fisher-Z applied to ranked data.

Native implementation. Captures monotonic but non-linear dependence that vanilla Fisher-Z would miss.

Initialise the test and (optionally) load a JSON p-value cache.

Parameters:
  • data – Sample matrix in shape (n, p).

  • cache_path – Optional path to a JSON cache file used to memoise p-values across calls. The cache is keyed by (data_hash, method_name, parameters_hash) and stamped with format_version so v0.1.0 caches can be detected and invalidated by future releases.

Raises:

TypeError – If kwargs contains keys outside cls.accepted_kwargs and cls._protocol_kwargs.

details(X: int, Y: int, condition_set: list[int] | None = None, **kwargs: Any) citk.tests.base.CITKResult[source]

Return a structured CITKResult for one CI query.

Default implementation calls __call__() and wraps the float p-value in a CITKResult. Subclasses with richer diagnostics (test statistic, df, n_effective) can override to populate those fields. cbcd’s algorithms only read .p_value from cached results, so this default is sufficient for cbcd interop.

supported_dtypes