segreg.bootstrap.boot_resample¶
- boot_resample(indep, dep, fitted_values=None, resid=None, resample_cases=False)[source]¶
A single boot resampling for a regression model.
If
resample_cases
is False (the default), then bothfitted_values
andresid
must be set. In this case, it is assumed that there is some (fitted) model of the form:\[y = f(x) + \epsilon\]and the
fitted_values
are \(\{f(x_i)\}\), whereindep
= \(\{x_1, x_2, \dots, x_n\}\). Ifresid
= \(\{\epsilon_1, \epsilon_2, \dots, \epsilon_n\}\), then this function takes a random sample with replacement fromresid
, \(\{\epsilon_1^*, \epsilon_2^*, \dots, \epsilon_n^*\}\), and returns\[\{f(x_i) + \epsilon_i^*\}\]as the resampled dependent values.
- Parameters
indep (array-like) – The independent data. Also called predictor, explanatory variable, regressor, or exogenous variable.
dep (array-like) – The dependent data. Also called response, regressand, or endogenous variable.
fitted_values (array-like of shape (len(indep),)) – The returned dependent data will be these values plus bootstrap residuals (random draws with replacement from
resid
).resid (array-like of shape (len(
indep
),)) – Residuals from which to draw a bootstrap resample (random sample with replacement).resample_cases (boolean, default False) – If True, the bootstrap will resample pairs with replacement from (
indep
,dep
). See Section 6.2.4 in Davison and Hinkley, “Bootstrap Methods and their Application”.
- Returns
indep_resample (numpy array) – When
resample_cases
is False (the default), the returned array is the inputindep
. That is, a copy is not made.dep_resample (numpy array)