residuals_plot

residuals_plot(model: Model) None

It plots the residuals \(\epsilon\) with respect to predicted values \(\hat{y}\).

Parameters

modelModel

The model with data, regressors, response variable and priors to be solved through Monte Carlo sampling.

Raises

TypeError

If model is not a Model.

ValueError
  • If a model.posteriors is None because the sampling has not been done yet,

  • if a posterior key is not a column of model.data,

  • if model.data is an empty pandas.DataFrame,

  • if model.response_variable is not a column of model.data.

Notes

Predicted values are computed at data points \(X\) using the posteriors means for each regressor’s parameter. In the case of linear model:

\[\hat{y_i} = \beta_0 + \sum_{j = 1}^{m} \beta_j x_{i,j}\]

while residuals are the difference between the observed values and the predicted values of the response_variable:

\[\epsilon_i = y_i - \hat{y_i}\]

See Also

LinearRegression