pod.fit_variance_model
fit_variance_model(X, y, mean_model, bandwidth_ratio=0.1, n_eval_points=100)Calculates residuals and prepares the grid for variance estimation.
This acts as the setup phase for the heteroscedasticity model. It computes the raw residuals from the mean model and defines the smoothing bandwidth.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| X | np.ndarray | The original input data. | required |
| y | np.ndarray | The original outcome data. | required |
| mean_model | Any | The fitted sklearn pipeline from fit_robust_mean_model. |
required |
| bandwidth_ratio | float | The kernel smoothing window size as a fraction of the data range (X_max - X_min). Defaults to 0.1. | 0.1 |
| n_eval_points | int | Number of points in the evaluation grid. Defaults to 100. | 100 |
Returns
| Name | Type | Description |
|---|---|---|
| Tuple[np.ndarray, float, np.ndarray] | Tuple[np.ndarray, float, np.ndarray]: - residuals: Raw differences between y and the mean model prediction. - bandwidth: The calculated smoothing window size (absolute units). - X_eval: A linearly spaced grid over the X domain for plotting/evaluation. |