nispace.stats.misc.residuals_nan
- nispace.stats.misc.residuals_nan(x, y, decenter=False)[source]
OLS residuals of
yonx(plus intercept), NaN-tolerant.NaN-tolerant sibling of
residuals(): rows where any ofx/yis NaN are dropped before fitting (vianp_any_axis1()), and NaN is restored at those positions in the output. Numba-compiled; requires plainnp.ndarrayinputs (no pandas). This is the version actually used throughout NiSpace: bycore/clean_y.pyfor covariate regression and bycore/colocalize.py’s_rank_regressto residualize X/Y against Z before correlating (the real mechanism behindmethod="partialpearson"/"partialspearman"incolocalize()— seenispace.stats.coloc.partialcorr()for the closed-form alternative that is not on this code path).- Parameters:
x (numpy.ndarray) – shape (n_values, n_predictors)
y (numpy.ndarray) – shape (n_values, 1) or (n_values,)
decenter (bool, optional) – add mean of y to residuals before return
- Returns:
1D array of residuals w or w/o added mean of y, NaN where input had NaN
- Return type:
numpy.ndarray