Repository navigation
ENH: add get_influence to DiscreteResults - #7951
Conversation
|
test failure: it looks like because GLM.resid_pearson does not divide by scale I need to go through the details to see where the |
|
if we want to use MLEInfluence with GLM, OLS and similar that have checking discrete_model for scale: Brief file search
ZI new score residual methods in MLEInfluence don't have unit tests, not even smoke. open questions: update copied to Logit from GLM brief explanation: general binary (cdf link), (if my derivation is correct) |
|
I'm running into problems trying to scale resid_pearson in GLMInfluence subclasses MLEInfluence and does not have it's own I need to decide whether GLMInfluence should be more like MLEInfluence or like OLSInfluence. update new issue #7955 for misspecification question |
|
Should be green now This changes that scaled resid_pearson is attached as The assumption now is that if resid is specified as argument in the Influence class, then it needs to be scaled and not unscaled resid_pearson. |
|
BinaryModel are a bit of a hybrid now, after I had added a to compare: In discrete count models, we don't have an alternative interpretation and attributes for log-link, exp-mean function. |
|
???? What's the interpretation of Generalized Leverage in zero-inflated models? The relevant function is Analytical derivative (with or without jump) are difficult, but not impossible. I could also use just the intensive margin without jump. One likely problem with numdiff is the division by the step size, the jump part shouldn't be normalized by step-size. update my current version of update 2 Then
|
|
doesn't look good for generalized leverage in zero-inflated models I found articles for influence measures in zero-inflated models, like cooks distance and similar with the generic definition. There is one article that has generalized leverage and zero-inflated in the title, but it seems to be only available in gated Chinese website. And the article doesn't show up in the authors pages at public research websites. maybe an alternative: looking at intensive and extensive margins separately (I didn't look at the following article) Yang, Yan, and Douglas G Simpson. 2012. “Conditional Decomposition Diagnostics for Regression Analysis of Zero-Inflated and Left-Censored Data.” Statistical Methods in Medical Research 21 (4): 393–408. https://doi.org/10.1177/0962280210387525. update I skimmed the article and it doesn't seem to have any influence outlier diagnostics. For now:
|
|
more about likelihood computation and dependence on endog, specifically ZI models:
in NBP, GPP, I added endog as extra argument to score_factor. score_factor there is self contained and only calls predict which does not depend on endog. So the endog, argument in score_factor reflects all effects of endog on score. in ZI models it is much trickier. However, endog might also affect other attributes in the model. The main design in statsmodels assumes that endog is fixed. This is a lot of duplicated work, However, it means that the mask is recomputed when I use numdiff and change endog internally. Similar pattern will occur in other switching, censoring, selection models, when we take a derivative wrt. a variable or parameter that affects regime membership of an observation. Bottomline, I guess, Even if likelihood is smooth and satisfies all regularity conditions wrt parameter, we might not have smoothness or regularity conditions for all post-estimation methods. The same will be true for local influence analysis, which we don't have yet. (I will be less surprised next time I run into weird numdiff results.) Garay, Aldo M., Elizabeth M. Hashimoto, Edwin M. M. Ortega, and Víctor H. Lachos. 2011. “On Estimation and Influence Diagnostics for Zero-Inflated Negative Binomial Regression Models.” Computational Statistics & Data Analysis 55 (3): 1304–18. https://doi.org/10.1016/j.csda.2010.09.019. Xie, Feng-Chang, Bo-Cheng Wei, and Jin-Guan Lin. 2008. “Assessing Influence for Pharmaceutical Data in Zero-Inflated Generalized Poisson Mixed Models.” Statistics in Medicine 27 (18): 3656–73. https://doi.org/10.1002/sim.3233. |
|
MLEInfluence methods that depend on hat_matrix
the other methods only depend on hat_matrix through Do we use a default hat_matrix_diag = zeros or = k_params / nobs? an alternative would be to use a different definition of leverage. In zi models we could base it on joint exog, but where we would have to remove duplicate (explanatory variables that are in both exog) edit I'm working with a constant only model. That implies that all observations have the same exog values. There are no influential points in terms of x-outliers. edit 2 For now, this PR:
|
|
I have it working in the last commit, but not verified numbers yet. in summary_frame we only have dfbetas, cooks_d and dffits/d_fittedvalues likelihood distance LD might also work |
|
This pull request introduces 2 alerts when merging 242b1f6 into d9f21bb - view on LGTM.com new alerts:
|
|
new plan
aside: Barros, Michelli, Manuel Galea, Víctor Leiva, and Manoel Santos-Neto. 2018. “Generalized Tobit Models: Diagnostics and Application in Econometrics.” Journal of Applied Statistics 45 (1): 145–67. https://doi.org/10.1080/02664763.2016.1268572. Tobit for elliptical/symmetric distribution Barros, Michelli, Manuel Galea, Manuel González, and Víctor Leiva. 2010. “Influence Diagnostics in the Tobit Censored Response Model.” Statistical Methods & Applications 19 (3): 379–97. https://doi.org/10.1007/s10260-010-0135-y. This one includes GL and standardized/studentized deviance and martingale residuals ! |
this should be at least my workaround in notebook with ZIP which does not have studentized residuals
However, k_vars in cooks_d is exog.shape[1] and not k_params, in zi example Aside: in overidentified GMM we don't have k_params == len(score) (number of moment conditions. I think articles on influence in ZIP and similar don't use the k_params normalization of cooks distance, ARAIR, and briefly checking on of the articles. One difference in implementation:
BetaModel has |
|
for docs: I will expand on the definitions for the various measures and differences in the MLEInfluence class docstring. We will need to add it to the rst docs. |
|
see issue #7964 for differences between Probit MLEInfluence and GLMInfluence. It looks like we get quite a bit different and ahead of other packages here. And we don't have local influence measures yet. |
|
exog in MLEInfluence:
options for multi-exog case
We need more cases of multi-exog models. What's the better design is unclear. BetaModel has generalized leverage hat_matrix_diag. I guess lazy access to Another alternative: |
|
This pull request introduces 2 alerts when merging 0273e14 into d9f21bb - view on LGTM.com new alerts:
|
|
I think I've got now all I want here. |
|
oops, I forgot to add |
|
This pull request introduces 2 alerts when merging cdeb4c5 into d9f21bb - view on LGTM.com new alerts:
|
cdeb4c5 to
7551cd3
Compare
|
This pull request introduces 2 alerts when merging 7551cd3 into d9f21bb - view on LGTM.com new alerts:
|
|
aside (as reminder): https://www.statsmodels.org/dev/pitfalls.html#other-problems Would be good to also mention this in the corresponding class docstrings but I need to amend the commit here first |
7551cd3 to
15e97c0
Compare
|
another idea: looking at outlier measure based on loglikeobs artificial example with add x and y outliers (model is ZeroInflatedPoisson) This plot (above) looks similar to resid_score and cooks_d index plots |
|
This pull request introduces 2 alerts when merging 15e97c0 into 9dd53ac - view on LGTM.com new alerts:
|
eef1827 to
61909db
Compare
|
I amended and removed duplicate import merging when green (I'm not sure what comes next, maybe diagnostic again if I can make up my mind about module locations) |
|
This pull request introduces 1 alert when merging 61909db into 9dd53ac - view on LGTM.com new alerts:
|


WIP still in design/decision stage
MLEInfluence with resid_pearson default
works for
Logit,
Poisson,
NegativeBinomialP,
GeneralizedPoisson,
other models are missing derivatives.
currently test failures because definition of
MLEInfluence.resid_studentizedchanged, in TestInfluenceGaussianGLMMLE.test_basics