Skip to content

ENH: Mutliple Equations/MNLogit wrapping improvements - #2197

Closed
jseabold wants to merge 9 commits into
statsmodels:masterfrom
jseabold:mnlogit-equations
Closed

jseabold wants to merge 9 commits into
statsmodels:masterfrom
jseabold:mnlogit-equations

Conversation

@jseabold

Copy link
Copy Markdown
Member

Closes #2147.

@jseabold

Copy link
Copy Markdown
Member Author

As part of this PR, I'd like to add support for selection of a reference category for MNLogit and mention the reference in the summary. Should be easy to do. #837

Needs to be added to release notes as well.

@josef-pkt josef-pkt mentioned this pull request Jan 22, 2015
29 tasks
@josef-pkt

Copy link
Copy Markdown
Member

@jseabold
I'd like to move this to 0.8
still several failures, changes or affects code all over the place, option for reference category is not working yet correctly
(and I'm not able to read through it very fast)

class MultinomialModel(BinaryModel):

def _handle_data(self, endog, exog, missing, hasconst, **kwargs):
reference = kwargs.pop('reference', 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just add reference=0 to the signature? Pushing back against the **kwargs pattern.

ynames = ["{0}={1}".format(yname, ynames[i]) for i in keys]
elif data_tools._is_using_pandas(endog, None):
# patsy goes through here
endog_dummies, ynames, yname = _pandas_to_dummies(endog)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily in this PR, but for pd.Categoricals a corner case to watch out for is when there are unused categories.

def bic(self):
return -2*self.llf + np.log(self.nobs)*(self.df_model+1)

def _get_endog_name(self, yname, yname_list):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for making this not-a-method

Comment thread statsmodels/base/data.py
return obj

def attach_columns(self, result):
return getattr(self, method_name)(obj, *names)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1. There's too much getattr and setattr as it is.

Comment thread statsmodels/base/data.py
def attach_columns(self, result):
return getattr(self, method_name)(obj, *names)

def attach_columns(self, result, *arg, **kwargs):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there existing cases when **kwargs get passed?

-----
See developer notes for further information on `MNLogit` internals.
""" % {'extra_params' : base._missing_param_doc}
""" % {'extra_params' : _mnlogit_extra_params}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is only used in one place, does why not just put it here?

@josef-pkt josef-pkt modified the milestones: 0.8, 0.10 Apr 27, 2018
@josef-pkt

Copy link
Copy Markdown
Member

This pull request introduces 2 alerts and fixes 1 when merging 778a7a4 into f4cf57c - view on lgtm.com

new alerts:

  • 2 for Module-level cyclic import

fixed alerts:

  • 1 for Module-level cyclic import

Comment posted by lgtm.com

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.

Use better equation names in MNLogit results

3 participants