You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
summary currently has autocorrelation and normality tests, but they are just available in the summary tables. Heteroscedasticity, outlier and (non)linearity diagnostics are missing.
I might also be nice to attach them as methods that cover several tests, .test_acorr, .test_het, .test_xxx? and also to attach the corresponding diagnostic regression plots.
Also doc examples for the whole enchilada, estimate, test, plot, alternative methods in the style of UCLA stats or a chapter in a textbook like Greene would be useful to see what's available and how to run them as user.
Do we really want a large collection of methods with test_xxx or should we add a generic method like test_diagnostic or test_specification? Or even something like get_diagnostics in analogy to OLSResults.
Should we add at least some minimal test_xxx for diagnostics as in some tsa models, and use a generic method for the rest?
Related question: Where do we put the tests that only apply to one model or a small group of models, i.e. where we don't have a general or generic version? For example testing for dispersion or excess zeros in Poisson.
add method get_diagnostics that returns an instance of a <model>Diagnostics class
This means I could add experimental versions of CountDiagnostics, PoissonDiagnostics.
This would also mean that we get a new class hierarchy to delegate to (instead of using Mixins), with some dispatch to the appropriate subclass. If the Diagnostics classes largely delegate to standalone functions, then this classes will mostly specify a convenient API but does not prevent standalone use of specific diagnostics as is now in the OLS diagnostic tests.
example: Poisson lm_test or score_test of under/overdispersion, zero-inflation or both (e.g. scoretest Poisson versus ZINB?).
similar score tests: ZIP overdispersion versus ZINB, ...
possible keywords 'direction' if we have score_test derived for specific alternative alternative is currently restricted to two-sided versus one-sided method for alternative versions of the test
It doesn't rule out that we add a few specific methods like a summary regression plot.
I just had the same idea again as in my last comment for get_specification_tests
A diagnostic class would allow us to collect all generic and model specific diagnostics and specification tests.
Outlier-influence diagnostics has a separate get method already (in linear regression models,/OLS, and GLM)
example count data like poisson
test for over dispersion, excess dispersion
test for zero-inflation, zero-modification
general gof test
reset test (is generic)
other variance/dispersion tests, e.g. heteroscedasticity
The actual tests should (mostly) be standalone functions, and the Diagnostics class can just delegate with the appropriate options.
The methods should return in general a Holder, HolderTuple instance.
The diagnostics class can include summary for the main results and plot methods.
stats.diagnostic is already taken with the old OLS diagnostics
influence_outlier classes are in specific stats module
in many cases we will need methods that are model/distribution specific with some generic cases like RESET tests
discrete.diagnostic doesn't exist yet, i.e. no diagnostic modules in model directories
If PoissonDiagnostic (or DiagnosticPoisson ?) class is in discrete, then we need to import it from there to genmod glm
similar for other families
size of modules
stats.diagnostic is at 1800 lines,
outlier_influence at 1300
discrete_diagnostic_count at 300 lines, but dispersion tests are still in generic CMT module
I guess I start with discrete.diagnostic and a Poisson Diagnostic
naming:
influence classes are XXXInfluence because Skipper had started with OLSInfluence.
get_prediction has currently only 2 PredictionResults classes, separately defined in genmod for GLM and in regression for OLS/WLS
gee has GEEMargins, GLM doesn't seem to have get_margeff yet (but I thought I had used it for GLM). discrete also has DiscreteMargins
test_dispersion: returns several results, several variants of dispersion tests
test_poisson_zero_inflation: has option for two test methods, but returns only the one selected
Do we return results from several test methods or only from one selected method?
a compromise would be to have method="all"
This applies as general issue, e.g.
test_nonlinear in OLS or others, which could include generic RESET test
problems with "all"
adding new methods breaks backwards compatibility
we possibly need several separate keyword for options in different tests
But this could also be an advantage, e.g. nonlinear tests that require sorting with respect to one exog.
slow tests, not all tests might be fast to compute by default, e.g. if we add bootstrap or similar tests
we could default to method="fast" that excludes slow methods
...
If we add a summary method to the Diagnostic classes, then we might want to show only one method for each category of tests.
Activity
josef-pkt commentedon Sep 5, 2017
The API is still not clear to me.
Do we really want a large collection of methods with test_xxx or should we add a generic method like test_diagnostic or test_specification? Or even something like get_diagnostics in analogy to OLSResults.
Should we add at least some minimal test_xxx for diagnostics as in some tsa models, and use a generic method for the rest?
Related question: Where do we put the tests that only apply to one model or a small group of models, i.e. where we don't have a general or generic version? For example testing for dispersion or excess zeros in Poisson.
Also, we need to avoid circular imports.
josef-pkt commentedon Sep 8, 2017
to get started:
add method
get_diagnosticsthat returns an instance of a<model>DiagnosticsclassThis means I could add experimental versions of CountDiagnostics, PoissonDiagnostics.
This would also mean that we get a new class hierarchy to delegate to (instead of using Mixins), with some dispatch to the appropriate subclass. If the Diagnostics classes largely delegate to standalone functions, then this classes will mostly specify a convenient API but does not prevent standalone use of specific diagnostics as is now in the OLS diagnostic tests.
example: Poisson lm_test or score_test of under/overdispersion, zero-inflation or both (e.g. scoretest Poisson versus ZINB?).
similar score tests: ZIP overdispersion versus ZINB, ...
possible keywords
'direction'if we have score_test derived for specific alternativealternativeis currently restricted to two-sided versus one-sidedmethodfor alternative versions of the testIt doesn't rule out that we add a few specific methods like a summary regression plot.
ENH: add diagnostics_count (not public), see statsmodels#130, statsmo…
ENH: add diagnostics_count (not public), see statsmodels#130, statsmo…
ENH: add diagnostics_count (not public), see statsmodels#130, statsmo…
jbrockmendel commentedon May 15, 2019
Possibly related to #4354
josef-pkt commentedon Nov 9, 2020
I just had the same idea again as in my last comment for
get_specification_testsA diagnostic class would allow us to collect all generic and model specific diagnostics and specification tests.
Outlier-influence diagnostics has a separate
getmethod already (in linear regression models,/OLS, and GLM)example count data like poisson
The actual tests should (mostly) be standalone functions, and the Diagnostics class can just delegate with the appropriate options.
The methods should return in general a Holder, HolderTuple instance.
The diagnostics class can include summary for the main results and plot methods.
josef-pkt commentedon Nov 18, 2020
location for diagnostic classes
stats.diagnostic is already taken with the old OLS diagnostics
influence_outlier classes are in specific stats module
in many cases we will need methods that are model/distribution specific with some generic cases like RESET tests
discrete.diagnostic doesn't exist yet, i.e. no
diagnosticmodules in model directoriesIf PoissonDiagnostic (or DiagnosticPoisson ?) class is in discrete, then we need to import it from there to genmod glm
similar for other families
size of modules
stats.diagnostic is at 1800 lines,
outlier_influence at 1300
discrete_diagnostic_count at 300 lines, but dispersion tests are still in generic CMT module
I guess I start with
discrete.diagnosticand a Poisson Diagnosticnaming:
PredictionResultsclasses, separately defined in genmod for GLM and in regression for OLS/WLSjosef-pkt commentedon Oct 17, 2022
Interface/API design issue:
PoissonDiagnostic has
Do we return results from several test methods or only from one selected method?
a compromise would be to have
method="all"This applies as general issue, e.g.
problems with "all"
But this could also be an advantage, e.g. nonlinear tests that require sorting with respect to one exog.
we could default to method="fast" that excludes slow methods
If we add a
summarymethod to the Diagnostic classes, then we might want to show only one method for each category of tests.