statsmodels.stats.outliers_influence.OLSInfluence#
- class statsmodels.stats.outliers_influence.OLSInfluence(results)[source]#
Class to calculate outlier and influence measures for OLS result
- Parameters:
- results
RegressionResults currently assumes the results are from an OLS regression
- results
- Attributes:
- cooks_distance
Cook’s distance
Uses original results, no nobs loop
Based on:
- Eubank, R. L. (1999). Nonparametric regression and spline
smoothing. CRC press.
- Cook’s distance. (n.d.). In Wikipedia. July 2019, from
- cov_ratio
covariance ratio between LOOO and original
This uses determinant of the estimate of the parameter covariance from leave-one-out estimates. requires leave one out loop for observations
det_cov_params_not_obsideterminant of cov_params of all LOOO regressions
- dfbeta
dfbeta
uses results from leave-one-observation-out loop
- dfbetas
dfbetas
uses results from leave-one-observation-out loop
- dffits
dffits measure for influence of an observation
- dffitsfloat
The dffits measure for each observation, which is a measure of the influence of a single data point on the predicted value of a model.
- dffits_thresholdfloat
The threshold to determine if the influence of an observation is large. The threshold is 2 * sqrt(k / n).
based on resid_studentized_external, uses results from leave-one-observation-out loop.
It is recommended that observations with dffits large than a threshold of 2 sqrt{k / n} where k is the number of parameters, should be investigated.
Based on Wikipedia
- dffits_internal
dffits measure for influence of an observation
based on resid_studentized_internal uses original results, no nobs loop
- ess_press
Error sum of squares of PRESS residuals
- hat_diag_factor
Factor of diagonal of hat_matrix used in influence
this might be useful for internal reuse h / (1 - h)
- hat_matrix_diag
Diagonal of the hat_matrix for OLS
- influence
Influence measure
matches the influence measure that gretl reports u * h / (1 - h) where u are the residuals and h is the diagonal of the hat_matrix
params_not_obsiparameter estimates for all LOOO regressions
- resid_press
PRESS residuals
- resid_std
estimate of standard deviation of the residuals
See also
resid_var.- resid_studentized
Studentized residuals using variance from OLS
alias for resid_studentized_internal for compatibility with MLEInfluence. This uses sigma from original estimate and does not require leave one out loop
- resid_studentized_external
Studentized residuals using LOOO variance
this uses sigma from leave-one-out estimates
requires leave one out loop for observations
- resid_studentized_internal
Studentized residuals using variance from OLS
this uses sigma from original estimate does not require leave one out loop
- resid_var
estimate of variance of the residuals
sigma2 = sigma2_OLS * (1 - hii)
where hii is the diagonal of the hat matrix
- sigma2_not_obsi
error variance for all LOOO regressions
This is ‘mse_resid’ from each auxiliary regression.
uses results from leave-one-observation-out loop
Methods
get_resid_studentized_external([sigma])Calculate studentized residuals
plot_index([y_var, threshold, title, ax, idx])Index plot for influence attributes
plot_influence([external, alpha, criterion, ...])Plot of influence in regression.
Creates a DataFrame with all available influence results
summary_table([float_fmt])Create a summary table with all influence and outlier measures
Notes
One part of the results can be calculated without any auxiliary regression (some of which have the _internal postfix in the name). Other statistics require leave-one-observation-out (LOOO) auxiliary regression, and will be slower (mainly results with _external postfix in the name). For the auxiliary LOOO regression, only the required results are stored.
Using the LOO measures is currently only recommended if the data set is not too large. One possible approach for LOOO measures would be to identify possible problem observations with the _internal measures, and then run the leave-one-observation-out only with observations that are possible outliers. (However, this is not yet available in an automated way.)
This should be extended to general least squares.
The leave-one-variable-out (LOVO) auxiliary regression are currently not used.
Methods
get_resid_studentized_external([sigma])Calculate studentized residuals
plot_index([y_var, threshold, title, ax, idx])Index plot for influence attributes
plot_influence([external, alpha, criterion, ...])Plot of influence in regression.
Creates a DataFrame with all available influence results
summary_table([float_fmt])Create a summary table with all influence and outlier measures
Properties
Cook's distance
covariance ratio between LOOO and original
determinant of cov_params of all LOOO regressions
dfbeta()uses results from leave-one-observation-out loop
dfbetas()uses results from leave-one-observation-out loop
dffits measure for influence of an observation
dffits measure for influence of an observation
Error sum of squares of PRESS residuals
Factor of diagonal of hat_matrix used in influence
Diagonal of the hat_matrix for OLS
Influence measure
parameter estimates for all LOOO regressions
PRESS residuals
estimate of standard deviation of the residuals
Studentized residuals using variance from OLS
Studentized residuals using LOOO variance
Studentized residuals using variance from OLS
estimate of variance of the residuals
error variance for all LOOO regressions