{"action":"created","issue":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4666","repository_url":"https://api.github.com/repos/statsmodels/statsmodels","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4666/labels{/name}","comments_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4666/comments","events_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4666/events","html_url":"https://github.com/statsmodels/statsmodels/issues/4666","id":324727141,"number":4666,"title":"FAQ-D/REF/ENH: use `results_class` attribute in general","user":{"login":"josef-pkt","id":440735,"avatar_url":"https://avatars1.githubusercontent.com/u/440735?v=4","gravatar_id":"","url":"https://api.github.com/users/josef-pkt","html_url":"https://github.com/josef-pkt","followers_url":"https://api.github.com/users/josef-pkt/followers","following_url":"https://api.github.com/users/josef-pkt/following{/other_user}","gists_url":"https://api.github.com/users/josef-pkt/gists{/gist_id}","starred_url":"https://api.github.com/users/josef-pkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josef-pkt/subscriptions","organizations_url":"https://api.github.com/users/josef-pkt/orgs","repos_url":"https://api.github.com/users/josef-pkt/repos","events_url":"https://api.github.com/users/josef-pkt/events{/privacy}","received_events_url":"https://api.github.com/users/josef-pkt/received_events","type":"User","site_admin":false},"labels":[{"id":84073496,"url":"https://api.github.com/repos/statsmodels/statsmodels/labels/FAQ","name":"FAQ","color":"fbca04","default":false},{"id":163856,"url":"https://api.github.com/repos/statsmodels/statsmodels/labels/comp-discrete","name":"comp-discrete","color":"ededed","default":false},{"id":163677,"url":"https://api.github.com/repos/statsmodels/statsmodels/labels/comp-genmod","name":"comp-genmod","color":"ededed","default":false},{"id":101509572,"url":"https://api.github.com/repos/statsmodels/statsmodels/labels/type-refactor","name":"type-refactor","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/statsmodels/statsmodels/milestones/11","html_url":"https://github.com/statsmodels/statsmodels/milestone/11","labels_url":"https://api.github.com/repos/statsmodels/statsmodels/milestones/11/labels","id":2546431,"number":11,"title":"0.10","description":"currently for issues, PR that will not be available or ready for 0.9","creator":{"login":"josef-pkt","id":440735,"avatar_url":"https://avatars1.githubusercontent.com/u/440735?v=4","gravatar_id":"","url":"https://api.github.com/users/josef-pkt","html_url":"https://github.com/josef-pkt","followers_url":"https://api.github.com/users/josef-pkt/followers","following_url":"https://api.github.com/users/josef-pkt/following{/other_user}","gists_url":"https://api.github.com/users/josef-pkt/gists{/gist_id}","starred_url":"https://api.github.com/users/josef-pkt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josef-pkt/subscriptions","organizations_url":"https://api.github.com/users/josef-pkt/orgs","repos_url":"https://api.github.com/users/josef-pkt/repos","events_url":"https://api.github.com/users/josef-pkt/events{/privacy}","received_events_url":"https://api.github.com/users/josef-pkt/received_events","type":"User","site_admin":false},"open_issues":228,"closed_issues":19,"state":"open","created_at":"2017-05-27T18:40:33Z","updated_at":"2018-05-20T18:28:07Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2018-05-20T17:43:01Z","updated_at":"2018-05-21T03:49:27Z","closed_at":null,"author_association":"MEMBER","body":"When we create a model that inherits the `fit` method, then it is convenient to have an attribute that tells the super class which results class to use for creating the results instance.\r\nThis is convenient if we have to override or add a few methods to the specific Results instance.\r\n\r\n- #2122 was an early issue for GenericLikelihoodModels\r\n- The discrete count models use it for ZeroInflated model, but uses `result_class` instead of `results_class`\r\n- statespace, GMM and distributed use `results_class` based on file search\r\n- RegressionModel.fit does a specific instance check for OLS, `isinstance(self, OLS)`\r\n  There might be more like this with hardcoded special cases that haven't been changed yet.\r\n- Some discrete model like Logit, CountModel have a fit method that essentially only creates the correct results instance and otherwise just delegates to the super(...).fit\r\n\r\nWe also need the results_wrapper_class, which is also used by statespace models\r\nzero inflated count model uses 4 classes, e.g.\r\n\r\n```\r\n        self.result_class = ZeroInflatedPoissonResults\r\n        self.result_class_wrapper = ZeroInflatedPoissonResultsWrapper\r\n        self.result_class_reg = L1ZeroInflatedPoissonResults\r\n        self.result_class_reg_wrapper = L1ZeroInflatedPoissonResultsWrapper\r\n```\r\n\r\nCurrently I'm working on subclasses of GLM and some discrete models which should also get an option for `results_class`. Penalized #4576 currently uses the default Results class without any specific information about the penalization, which needs to be changed.\r\n\r\nThere are a few more issues or comments in other issues related to this.\r\n\r\nSo, I think we should add it as general feature for the model classes.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/statsmodels/statsmodels/issues/comments/390545911","html_url":"https://github.com/statsmodels/statsmodels/issues/4666#issuecomment-390545911","issue_url":"https://api.github.com/repos/statsmodels/statsmodels/issues/4666","id":390545911,"user":{"login":"jbrockmendel","id":8078968,"avatar_url":"https://avatars1.githubusercontent.com/u/8078968?v=4","gravatar_id":"","url":"https://api.github.com/users/jbrockmendel","html_url":"https://github.com/jbrockmendel","followers_url":"https://api.github.com/users/jbrockmendel/followers","following_url":"https://api.github.com/users/jbrockmendel/following{/other_user}","gists_url":"https://api.github.com/users/jbrockmendel/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrockmendel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrockmendel/subscriptions","organizations_url":"https://api.github.com/users/jbrockmendel/orgs","repos_url":"https://api.github.com/users/jbrockmendel/repos","events_url":"https://api.github.com/users/jbrockmendel/events{/privacy}","received_events_url":"https://api.github.com/users/jbrockmendel/received_events","type":"User","site_admin":false},"created_at":"2018-05-21T03:49:27Z","updated_at":"2018-05-21T03:49:27Z","author_association":"CONTRIBUTOR","body":"There is precedent in [statespace](https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/statespace/mlemodel.py#L486) and [regime_switching](https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/regime_switching/markov_switching.py#L1041)\r\n\r\nAs discussed elsewhere (and FUDed to death, obviously, #3877), implementing such a thing can save a _ton_ of duplicated code, in particular in `discrete_model`.  An example of what this [can look like](https://github.com/jbrockmendel/sm2/blob/master/sm2/discrete/discrete_model.py#L424).\r\n\r\nDefining these attributes in `__init__` is sub-optimal.  Too many attributes are already defined in `__init__/initialize/_initialize/_handle_data` and with layered `super` calls it is not nearly obvious enough what attributes are defined where.  More to the point: the desired Results subclass is class-specific, so should be defined at the class-level ."}}
{"actor":{"display_login":"jbrockmendel"}}