Skip to content

ENH: influence measure - general for MLE and M-estimators #4257

Open

Description

@josef-pkt

edit see #4732 for updated information and implementation

(a random find)

Hosmer,Lemeshow, and May in chapter 8 refer to a influence function definition of Cooks Distance and use score residuals. They refer it to a Rand working paper that I don't have access to.
Their application is exponential and weibull survival or failure time model (AFT)

this is essentially
cov_params dot score_obs_i
and quadratic form (cooks distance
score_obs_i dot cov_params dot score_obs_i

Hosmer, David W., Stanley Lemeshow, and Susanne May. 2008. Applied Survival Analysis: Regression Modeling of Time-to-Event Data. 2nd ed. Wiley Series in Probability and Statistics. Hoboken, N.J: Wiley-Interscience.

Hall, Gaineford J., William H. Rogers, and Daryl Pregibon. "Outliers matter in survival analysis." (1982).
Rand working paper, no open access version is available

I haven't found any directly related article (in a brief search)

of related interest
influence of an observation on prediction (fittedvalues)

aside: AFAICS, most of the GLM influence literature uses the analogue to linear models (related to use of IRLS), and does not directly use a general definition. (related also to generalized projection matrix, ...)

Activity

  1. added this to the 0.10 milestone on Feb 18, 2018
  2. josef-pkt commented on Feb 20, 2018

    @josef-pkt
    MemberAuthor

    Collett has a bit more on this and also refers to Hall et al 1982
    section 7.4 starting on page 242, gives two summary measures for influence of an observation, one based on cov_params, the other based on OPG, with different normalization in the two cases

    Collett, D. 2003. Modelling Survival Data in Medical Research. 2nd ed. Chapman & Hall/CRC Texts in Statistical Science Series. Boca Raton, Fla: Chapman & Hall/CRC.

  3. josef-pkt commented on Feb 22, 2018

    @josef-pkt
    MemberAuthor

    One often cited articles is Cook, but it's difficult for me to read (too much graphical/curvature arguments), and similar for followup literature
    It's better to read the robust literature on influence functions again under this focus, eg. Hampel et al book or articles by Carroll Ruppert.
    i.e. the basic influence function is just
    derivative of moment condition/estimating equation dot moment condition
    which is in the MLE case hessian dot score_obs

    once we have this we should be able to compute the followup influences, e.g. on prediction

    that is, write the generic code for M-estimators and specialize for MLE and then GLM and other models.
    (which will also go back from influence_outlier detection to robust estimation as in the linear model)

  4. josef-pkt commented on May 3, 2018

    @josef-pkt
    MemberAuthor

    related: using the trace of a generalized version of a hat matrix (influence on prediction) to get a general definition of effective degrees of freedom.

    I'm a bit stuck getting effective degrees of freedom, e.g. for AIC and BIC, in general penalized MLE or general M-Estimators, with penalized Poisson as special case. (#4576)
    It looks like we need several derivative related to the influence measures if we want to avoid exploiting the structure of a specific model each time. (I guess also related to the derivatives used in Margins.)

  5. josef-pkt commented on May 4, 2018

    @josef-pkt
    MemberAuthor

    to hat matrix for general MLE, M-Estimators

    I worked through the math and it looks like the outer part does not need to change from the unpenalized version, the inner part is the Hessian which is penalized.
    Analogy: hat matrix in Ridge regression
    http://statweb.stanford.edu/~tibs/sta305files/Rudyregularization.pdf page 27
    S = Z (Z' Z + λ I)^{-1} Z'
    i.e. only the unscaled cov_params normalized_cov_params in the inner part is affected.
    The outer parts are the Jacobians of the mean function in nonlinear OLS, and the weights are added for WLS.

    according to my derivation, the general form is
    hat matrix[j, i] = d E(y_j)/d y_i = d y_j / d params * (-Hessian_penalized) * d score / d y_i
    which is essentially the influence function of a (marginal) change in y_i on the prediction of y_j

  6. josef-pkt commented on Jun 10, 2018

    @josef-pkt
    MemberAuthor

    another one: deletion diagnostic for GMM

    Shi, Lei, Jun Lu, Jianhua Zhao, and Gemai Chen. 2016. “Case Deletion Diagnostics for GMM Estimation.” Computational Statistics & Data Analysis 95 (March): 176–91. https://doi.org/10.1016/j.csda.2015.10.003.

    equivalents for dfbeta, cooks distance, leverage (hat_matrix_diag) and GMM residual (squared)

    looks good (1 citation) and not too difficult to implement,
    looks only at overidentified case for efficient GMM (weights is cov(score_obs)), takes effect of deletion on weight matrix into account
    I think it will not apply to weight matrices that include correlation across observations, like HAC.
    The results should simplify for exactly identified case, but they only have a short comment and no special case formulas, i.e. when weights don't affect params, only inference. But I guess dfbeta computation will follow from the proof for the identified case, i.e. just drop the weights change component.
    (I read only half of the article.)

  7. josef-pkt commented on Jun 11, 2018

    @josef-pkt
    MemberAuthor

    Another distinction that wasn't clear to me:

    The hat matrix and standardized residual computation in OLS/WLS/GLM mixes computation of param estimator and inference for the estimator. e.g. w x (X W X)^{-1} x w is the variance of predicted wendog under nonrobust cov_type assumptions but it's also based on the hessian or EIM in the one-step updating for estimating params (and dfbeta), or projection matrix for the estimated expected value of the respons. Similar standardization or pearson or deviance residual divides by (1 - h_ii) which is the estimated variance of the residual (using cov_params).

    That is, we want dfbeta based on the algorithm to estimate params, but inference or standardization for or with it based on cov_params (so we can reuse a sandwich cov_params). However, that is not separated in any or most of the standard references.

    In MLE or standard least squares it doesn't matter because hessian or EIM (or OPG) is used for both.

    implication: I need the analog of get_prediction sandwich/cov_params based standard errors also for resid.

    (This will have to wait until I read through the "non-standard" influence and diagnostic literature.)

  8. josef-pkt commented on Jun 19, 2018

    @josef-pkt
    MemberAuthor

    leverage/hat_matrix_diag for general MLE, in preparation for #4732

    I found an article with the general definition for MLE based on leverage = d fittedvalues / d endog_i.
    (It is close to what I almost derived by hand.)
    Wei, Bo‐Cheng, Yue‐Qing Hu, and Wing‐Kam Fung. "Generalized leverage and its applications." Scandinavian Journal of statistics 25, no. 1 (1998): 25-37.

    leverage_i = d fitted_i / d params * (-hessian)^{-1} * d score / d endog_i

    see #4751 for required model specific derivatives

    for GLM:

    so = self.score_obs / self.results.resid_response[:, None]
    dmu_dp = 1 / self.results.model.family.link.deriv(self.results.fittedvalues)
    h = ((dmu_dp[:, None] * ex) * np.linalg.solve(-self.hessian, so.T).T).sum(1)
    
    np.max(np.abs(h - infl.hat_matrix_diag))
    1.2490009027033011e-16
    

    where infl.hat_matrix_diag is the hatmatrix coded from the explicit formula for GLM.
    example is GLM-Logit

    This definition of general leverage is used in several articles for accelerated failure time models (e.g. Log-Birnbaum-Saunders), Beta Regression ( https://rdrr.io/rforge/betareg/man/gleverage.html ), and IIRC tobit and ZINB based on "influence" articles that I read or skimmed,

  9. josef-pkt commented on Nov 29, 2021

    @josef-pkt
    MemberAuthor

    The definition of Generalized leverage and generic version in MLEInfluence for BetaModel matches R betareg.

    The "hatmatrix" in R betareg seems to take the dispersion parameter as fixed and doesn't match generalized leverage.
    MLEInfluence uses generalized leverage as "hat_diag", we don't have separate hatmatrix.

    My definition of studentized score residual in MLEInfluence.resid_studentized does not us hf for second parameter precision.
    My guess now is that it should depend on the hf matrix, i.e. take the effect of second parameter into account.
    What's the joint covariance of (multi-part) score_factor?
    I would need to go through the math and maybe match up with some special cases that might be analyzed in articles.

  10. josef-pkt commented on Nov 29, 2021

    @josef-pkt
    MemberAuthor

    after PR #7912 MLEInfluence should work with extra params, like BetaModel and GPP, NBP but still has several limitations

    • requires score and hessian factor
    • interpretation assumes that we have a mean parameterization, i.e. first link/ilink and exog is for the mean. and first score_factor and hessian factor depend on this. specifically it also assumes that model.predict() is the mean.

    For influence and outlier we might be able to generalize the second for other moment conditions than mean function, if we have an empirical moment for each observation (e.g. for variance we usually use squared residual).

    Otherwise, we need to create a limited MLEInfluence, e.g. d_params, dfbetas are always available, similarly cooks distance.
    The hatmatrix_diag/leverage depends on definition of derivative of score wr.t. endog. I guess this does not depend on the interpretation for predict. but parts that parts that depend on _deriv_mean_dparams will not be available for models without mean parameterization.
    We might be able to target other moments/statistics than mean to replace _deriv_mean_dparams with other predict which.

    Possible cases to look for are accelerated failure time, AFT, models, and maybe influence literature for flexible distributions,
    (I don't remember having ever looked at influence measures for those.)

  11. josef-pkt commented on Nov 23, 2023

    @josef-pkt
    MemberAuthor

    continuing with extra params

    Cook, R. Dennis. “[Influential Observations, High Leverage Points, and Outliers in Linear Regression]: Comment.” Statistical Science 1, no. 3 (August 1986): 393–97. https://doi.org/10.1214/ss/1177013623.

    Has a good discussion about whether an outlier-influence measure in the linear model is affected by changes in beta or scale/sigma or both, e.g. he mentions 3 likelihood displacements for beta, sigma and both.

    extending this idea
    We might want to add partial cooks distance and similar that only applies to a subset of parameters, e.g. leaving out scale/dispersion parameters in NegBin, ..., or, e.g. separate Cook's distances for mean and variance/precision parameters in Beta regression.
    currently MLEInfluence only considers measure for all parameters or individual parameters but not subsets.

    similar would be to include influence on specific measures corresponding to distribution parameter, e.g. dmean, dprecision for change in predicted mean (or linear predictor) and, resp., precision/var when dropping one observation.
    dffit is already doing this for cases where mean does not depend on extra params.

    another set of case:
    zero-inflated or other two-part models where we could provide subset measures that affect only parts of the model, e.g. the which in predict.

    using Cook's distance as "gate keeper"
    Cook states that if cook's distance for an observation is small, then all measures for individual params will also be small. So if p C distance is small we don't need to look further. (last paragraph before section 7 with references)
    I don't know if something like this also applies to more complicated models like beta regression, but this idea should work at least in many cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions