nispace.stats.coloc.partialpearson

nispace.stats.coloc.partialpearson(x, y, z)[source]

Closed-form partial Pearson correlation between x and y, controlling for z.

Equivalent to partialcorr(x, y, z, rank=False), without the branch.

Parameters:
  • x (np.ndarray, shape (n,), dtype float) – Numba-jitted: must be plain 1D np.ndarray instances of equal length. Does not handle NaN – strip/mask NaN entries before calling.

  • y (np.ndarray, shape (n,), dtype float) – Numba-jitted: must be plain 1D np.ndarray instances of equal length. Does not handle NaN – strip/mask NaN entries before calling.

  • z (np.ndarray, shape (n,), dtype float) – Numba-jitted: must be plain 1D np.ndarray instances of equal length. Does not handle NaN – strip/mask NaN entries before calling.

Returns:

rp – Partial correlation coefficient between x and y.

Return type:

float

Notes

Not on NiSpace’s live colocalize() code path: method=”partialpearson” there is computed by residualizing X/Y against Z first (core/colocalize.py’s _rank_regress -> residuals_nan) and then correlating the residuals with plain pearson, not by this closed-form formula. Imported into api.py’s namespace but not called there either – provided as a standalone utility.