statsmodels.stats.outliers_influence.MLEInfluence#
- class statsmodels.stats.outliers_influence.MLEInfluence(results, resid=None, endog=None, exog=None, hat_matrix_diag=None, cov_params=None, scale=None)[source]#
Global Influence and outlier measures (experimental)
- Parameters:
- results
instanceofresultsclass This only works for model and results classes that have the necessary helper methods.
- resid
ndarray,optional Residuals to use instead of the default
resid_pearsoncomputed from the results instance.- endog
ndarray,optional Endogenous (response) variable to use instead of
results.model.endog.- exog
ndarray,optional Exogenous (design) variable to use instead of
results.model.exog.- hat_matrix_diag
ndarray,optional Diagonal of the generalized leverage to use instead of the value computed internally.
- cov_params
ndarray,optional Covariance matrix of the parameter estimates to use instead of
results.cov_params().- scale
float,optional Scale parameter to use instead of
results.scale.
- results
- Attributes:
- hat_matrix_diag (hii)
Thisisthegeneralizedleveragecomputedasthe local derivative of fittedvalues (predicted mean) with respect to the observed response for each observation. Not available for ZeroInflated models because of nondifferentiability.
- d_params
ChangeinparameterscomputedwithoneNewtonstepusingthe full Hessian corrected by division by (1 - hii). If hat_matrix_diag is not available, then the division by (1 - hii) is not included.
- dbetas
changeinparametersdividedbythestandarderrorofparameters from the full model results,
bse.- cooks_distance
quadraticformforchangeinparametersweightedby cov_paramsfrom the full model divided by the number of variables. It includes p-values based on the F-distribution which are only approximate outside of linear Gaussian models.- resid_studentized
InthegeneralMLEcaseresid_studentizedare computed from the score residuals scaled by hessian factor and leverage. This does not use
cov_params.- d_fittedvalues
localchangeofexpectedmeangiventhechangeinthe parameters as computed in
d_params.d_fittedvalues_scaledsameasd_fittedvaluesbutscaledbythestandardChange in fittedvalues scaled by standard errors
- params_one
istheonestepparameterestimatecomputedasparams from the full sample minus
d_params.
- hat_matrix_diag (hii)
Methods
plot_index([y_var, threshold, title, ax, idx])Index plot for influence attributes
plot_influence([external, alpha, criterion, ...])Plot of influence in regression.
resid_score([joint, index, studentize])Score observations scaled by inverse hessian
Score residual divided by sqrt of hessian factor
Creates a DataFrame with influence results
Notes
MLEInfluence uses generic definitions based on maximum likelihood models.
MLEInfluence produces the same results as GLMInfluence for canonical links (verified for GLM Binomial, Poisson and Gaussian). There will be some differences for non-canonical links or if a robust cov_type is used. For example, the generalized leverage differs from the definition of the GLM hat matrix in the case of Probit, which corresponds to family Binomial with a non-canonical link.
The extension to non-standard models, e.g. multi-link model like BetaModel and the ZeroInflated models is still experimental and might still change. Additionally, ZeroInflated and some threshold models have a nondifferentiability in the generalized leverage. How this case is treated might also change.
Warning: This does currently not work for constrained or penalized models, e.g. models estimated with fit_constrained or fit_regularized.
This has not yet been tested for correctness when offset or exposure are used, although they should be supported by the code.
Status: experimental. This class will need changes to support different kinds of models, e.g. extra parameters in discrete.NegativeBinomial or two-part models like ZeroInflatedPoisson.
Methods
plot_index([y_var, threshold, title, ax, idx])Index plot for influence attributes
plot_influence([external, alpha, criterion, ...])Plot of influence in regression.
resid_score([joint, index, studentize])Score observations scaled by inverse hessian
Score residual divided by sqrt of hessian factor
Creates a DataFrame with influence results
Properties
Cook's distance and p-values
Change in expected response, fittedvalues
Change in fittedvalues scaled by standard errors
Approximate change in parameter estimates when dropping observation
Scaled change in parameter estimates
Diagonal of the generalized leverage
Diagonal of the hat_matrix using only exog as in OLS
Parameter estimate based on one-step approximation
Studentized default residuals