API reference

andrey.core.ci_missing.TestwiseDeletion#

class andrey.core.ci_missing.TestwiseDeletion(data, build, *, name, test_class, continuous, check_copies)[source]#

A conditional-independence test that deletes rows per test on data with missing values.

Built by make_indep_test() over data holding NaN. A query of x and y given S keeps the rows observed in every one of the columns {x, y} | S, builds the registered test over that block, its columns in data order, and returns that test’s p-value for the query. Queries are canonicalized as FisherZ’s are. The test of a block answers every later query over the same columns; the blocks the reused tests hold stay within _CACHE_BYTES, the least recently used dropped first. A nonlinear or a registered test, whose state grows with its queries, is built anew for each query. A partial-correlation test gets the GaussianDeletion subclass, which builds no test per block.

A query raises ValueError when its block has fewer rows than its test needs: 2, or |S| + 3 for "fisherz" and "student_t", the rows their degrees of freedom need; when a continuous column is constant on the block, as a constant column of the data is rejected before a fit; and when the test fails on the block or gives a p-value that is not a number, as a mixed-data test can on a block with fewer rows than columns. A categorical column with one category on the block is left to the test.

Parameters:
  • data (ndarray) – Values with NaN marking the missing ones; no infinities.

  • build (Callable[[ndarray, list[int]], CITest]) – build(block, columns) builds the registered test over block, the kept rows of columns.

  • name (str) – The indep_test name, for the messages.

  • test_class (type | None) – The class build returns, None for a registered test. It decides which of the partial-correlation methods the wrapper offers, what it reuses, and its BLAS pinning.

  • continuous (ndarray | None) – Marks the continuous columns, which a block may not hold constant; None marks none.

  • check_copies (bool) – Raise CopiedColumnsError when a partial-correlation block holds columns that repeat others up to scale and shift, as make_indep_test() does on complete data.

statistic_pvalues(x, y, conditions)[source]#

Statistics and p-values of many queries, each from the test over its own rows.

x and y are (N,) int arrays and conditions the (N, m) int array of conditioning sets; entry i is the block test’s statistic_pvalues of query i. A block test without that method reports only p-values: its statistic is p_value_statistic() of the p-value.

Return type:

tuple[ndarray, ndarray]