statsmodels / statsmodels

Statsmodels: statistical modeling and econometrics in Python
http://www.statsmodels.org/devel/
BSD 3-Clause "New" or "Revised" License
9.99k stars 2.87k forks source link

ENH: score_test for multi-link and multi-parameter (multi distribution args) models #7821

Open josef-pkt opened 2 years ago

josef-pkt commented 2 years ago

add score

My current score_test for models has two versions

Models with extra params that are constant, e.g. NegBin and GPP We need to extend score_test for the mean model. However, If the constant extra-params case is the null model, then we could test exog dependent, varying parameter as in the multi-link case.

Multi-link models: Models with exog dependent dispersion or scale, BetaModel and #7793 One possible specification test is testing that scale (extra params) is constant, i.e. coefficients of (slope) explanatory variables are zero. Implementation would need to handle multiple score_factors and hessian_factors.

Multi-part models: e.g. zero-inflation which uses internally two submodels to delegate to. Possible specification test: constant versus varying, exog-dependent zero-inflation. Implementation may be able to delegate to submodels.

7597 includes specification test for poisson about poisson versus zero-inflated or zero-modified poisson

josef-pkt commented 2 years ago

One problem for multi-link model is that we have different exog with inconsistent names across models. We need to find a way to specify which link/exog gets the exog_xxx_extra.

I guess we need to delegate some parts to the specific model. The variable addition usecase is important enough to do some extra work for it.

I guess, we will have a similar problem extending fit_constrained to multi-link, multi-exog models if we follow the current pattern of exog transformation. (maybe switching to constrained optimizers will be simpler) Also, using the transformation approach does not allow "cross-equation" restrictions when we have multiple exog

another design question: Do we append extra score/hess at the end or insert next to model exog_xxx? I guess inserting is easier if we reuse or follow the pattern of model score_obs and hessian. Appending at the end would be more useful when we split into new and old moment conditions.

josef-pkt commented 1 year ago

reference and comments on generalized residuals (score_factor) https://github.com/statsmodels/statsmodels/issues/7897#issuecomment-1514888372