Skip to content

REF/ENH: add CountResults.get_diagnostic - #7895

Merged
josef-pkt merged 1 commit into
statsmodels:mainfrom
josef-pkt:diagnostic_count
Nov 23, 2021
Merged

josef-pkt merged 1 commit into
statsmodels:mainfrom
josef-pkt:diagnostic_count

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

another round of diagnostics, see #7894 for possible additional diagnostics

  • add CountResults.get_diagnostic, and separate method for PoissonResults

@lgtm-com

lgtm-com Bot commented Nov 19, 2021

Copy link
Copy Markdown

This pull request introduces 1 alert when merging bf38cde into 8c1bfe7 - view on LGTM.com

new alerts:

  • 1 for Missing call to `__init__` during object initialization

@josef-pkt

Copy link
Copy Markdown
Member Author

Not sure what I want to do here.

I'm currently interested in post-estimation infrastructure and "framework", not so much on going through and adding individual tests.

The only "generic" test, I can think of right now, would be reset/link test for models that already implement score_test.

General tools for binning need to be cleaned up or added. e.g. this PR adds a limit on y_values for which=prob in chisquare test. A better binning will be needed, for example if small y=k have very low probabilities.

@josef-pkt

Copy link
Copy Markdown
Member Author

I'm going to add the full class hierarchy with DiagnosticDiscrete on top, even if some are empty for now.

e.g. I have Hosmer-Lemeshow type test for binary (AFAIR) and multinomial/ordinal and one plot for binary with lowess smoothed endog. HL already has unit tests for several models.

I'm not sure where DiagnosticBase and DiagnosticContinuous should go.
For Continuous I would like to get at least PIT and then also y-binned chisquare.

not decided yet:
GLMResults.get_diagnostic: Do I reuse the discrete diagnostic classes, or do we add GLM diagnostic subclass, or do skip/ignore it?
Main issue is extra params (scale/dispersion parameters) which we have as part of full MLE models but not in GLM except as fixed (in NegBin) or auxiliary parameter.

@josef-pkt

josef-pkt commented Nov 21, 2021 •

Copy link
Copy Markdown
Member Author

I have dropped cached probs_predicted, however it is currently needed.

I want to limit for how many y-values we compute "prob", but I also want to cache it.
Currently y_max = endog.max()

One possibility is to add y_max in results.get_diagnostic.
If we cache it, then all further analysis can use only probs that go up to y_max.
Alternative is to recompute probs if y_max is too small. Then, we could also allow y_max=0 or y_max = -1 as signal not to cache the probs.

This will get messier if we want to limit probs to bins or arbitrary sets of y_values, e.g. if endog/mean is large.
Those cases are not supported yet

A similar problem will show up in continuous diagnostic if diagnostic measures and test use y-bins.

update amended commit with y_max and force pushed

@josef-pkt

Copy link
Copy Markdown
Member Author

I'm going to merge this soon.

I need BetaModel for design issues for post-estimation of multi-exog models.
e.g. score_test #7827 (comment)

@josef-pkt
josef-pkt merged commit 0fe9ca4 into statsmodels:main Nov 23, 2021
@josef-pkt
josef-pkt deleted the diagnostic_count branch October 19, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant