Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

regression

regression

Standalone OLS regression on numpy arrays.

Pedagogical helper used in tutorials and notebooks where callers want a (b, se, t, p, df, res) tuple from a design matrix X and response Y without constructing a BrainData or Glm. For 4D neuroimaging data use BrainData.fit with model='glm'.

Methods:

NameDescription
regressFit an OLS regression of Y on X.

Methods

regress

regress(X, Y, *, method: str = 'ols', stats: str = 'full', tail: int | str = 2)

Fit an OLS regression of Y on X.

Does not add an intercept — include one in X explicitly. If Y is 2D, a separate regression is fit to each column.

Parameters:

NameTypeDescriptionDefault
XDesign matrix, shape (n_samples, n_regressors).required
YResponse, shape (n_samples,) or (n_samples, n_targets).required
methodstrOnly 'ols' is supported in v0.6.0. The legacy 'robust' and 'arma' methods were dropped; use statsmodels or a dedicated package if you need them.‘ols’
statsstr'full' returns the 6-tuple below; 'betas' returns just b; 'tstats' returns (b, t).‘full’
tailint | str2‘two’ (two-tailed, default) or 1

Returns:

NameTypeDescription
tuple(b, se, t, p, df, res) when stats='full':
- b: coefficients
- se: standard errors
- t: t-statistics
- p: p-values (per tail)
- df: residual degrees of freedom
- res: residuals