Implement two functions.
ols(X, y) - ordinary least squares with an intercept. Prepend a column of ones to X of shape (n, p) and return the (p + 1,) coefficient vector, intercept first. Use np.linalg.lstsq(..., rcond=None).
omitted_variable_bias(X, y, omit_idx) - for an X with exactly 2 columns, drop column omit_idx and return the tuple (full_kept, short, bias):
full_kept - the coefficient on the kept regressor in the full two-regressor fitshort - the coefficient on the kept regressor when the other is omittedbias - the predicted bias , where is the slope from regressing the omitted variable on the kept oneThe omitted-variable bias identity says these satisfy short == full_kept + bias.
np.column_stack([np.ones(len(X)), X]) builds the design matrix.ols is reused three times - full fit, short fit, and the auxiliary regression of omitted on kept.