nispace.stats.misc.partial_residuals_nan

nispace.stats.misc.partial_residuals_nan(x_nuisance, x_protect, y)[source]

Partial residuals: regress x_nuisance from y while controlling for x_protect.

Fits a joint model [x_nuisance | x_protect | intercept] so that nuisance coefficients are estimated controlling for the protected variables, then removes only the nuisance component. The protected effects (e.g. group differences) are preserved in the returned values.

Parameters:
  • x_nuisance (numpy.ndarray) – shape (n, p) — confounds to remove

  • x_protect (numpy.ndarray) – shape (n, q) — variables to control for but keep

  • y (numpy.ndarray) – shape (n,)

Returns:

shape (n,), NaN where input had NaN

Return type:

numpy.ndarray