Repository navigation
Description
We need to create new results instances in several methods, and we could drop some code duplication (where fit is overridden just to get the right results instance)
related #1093 was main issue to recreate or clone models
need to collect issues, and get more general solution,
Right now, we have some specific solutions in various new methods or methods under development, latest installment PenalizedMixin, fit_regularized and various fit_reparameterized
PR #2374 #2385 for penalized
no PR yet for the fit_reparameterized variants, similar to poisson and glm fit_constrained
one possible solution is fit(maxiter=0) which needs to be consistently implemented and unit tested
Done for GLM: #1728 reopened method='nm' works, default method (irls) doesn't have params (is None)
update
#2374 not has a LikelihoodModel._fit_zeros method that implements creating a results instance and modifying it based on a auxiliary transformed/reduced regression with generic tests for OLS, WLS, Logit, Poisson, NegativeBinomial, GLM and RLM. skips GEE, other models are not yet in base test_generic_methods. Two methods that use this are PenalizedMixin.fit and LikelihoodModel._fit_collinear with additional unit tests.
This is now a working solution and a good starting point for more refactoring for consistency across models and for finding a less hacky solution.
One possible direction is to provide similar or pieces of it for similar use cases, e.g. if we already have the parameter estimates from a different (non-scipy) optimizer like coordinate descend, then we don't need an auxiliary model and could just adjust the covariance of params (normalized_cov_params/hessian_inv and cov_params_default)
one main problem:
retrofitting an existing results instance is fragile:
It is difficult to avoid cached attributes and updating all required attributes. (This was one major reason to move cov_type into fit)
I ran into problems going the fit(maxiter=0) and adjust attributes route, in PR #2374 08c919d especially with RLM, and I haven't started with robust cov_types yet in other models.
two possibilities:
- don't retrofit, make it possible to create a new results instance
- move all but the basic code out of
results.__init__into an_initializemethod, that can be called to "cleanly" retrofit a results instance
Activity
josef-pkt commentedon May 12, 2015
related: AFAIR, results classes
__init__don't have a consistent signature, e.g. discrete versus OLS versus GLM.ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393
ENH: add LikelihoodModel._fit_zeros, several hacks see statsmodels#2393