residuals¶
- LinearModel.residuals() DataFrame
It computes the residuals \(\epsilon\) with respect to predicted values \(\hat{y}\).
Returns¶
pandas.DataFrameReturns a copy of
datawith 3 more columns:'intercept','predicted'and'residuals'.
Raises
ValueErrorif
response_variableis not a column ofdata,If a
posteriorsisNonebecause the sampling has not been done yet.
Notes
Predicted values are computed at data points \(X\) using the posteriors means for each regressor’s parameter:
\[\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}\]