Skip to content

Dimension Error in MultinomialResults summary2 - #3649

Closed
jbrockmendel wants to merge 17 commits into
statsmodels:masterfrom
jbrockmendel:ruthless_deletion
Closed

jbrockmendel wants to merge 17 commits into
statsmodels:masterfrom
jbrockmendel:ruthless_deletion

Conversation

@jbrockmendel

Copy link
Copy Markdown
Contributor

This is not a PR so much as documenting places where if __name__ == ... may be obsolete and -- more importantly -- a failing smoke test in MultinomialResults.summary2.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

======================================================================
ERROR: statsmodels.discrete.tests.test_discrete.test_mnlogit_factor
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/miniconda2/envs/statsmodels-test/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/travis/miniconda2/envs/statsmodels-test/lib/python2.7/site-packages/statsmodels-0.8.0-py2.7-linux-x86_64.egg/statsmodels/discrete/tests/test_discrete.py", line 1436, in test_mnlogit_factor
    summary2 = res.summary2()
  File "/home/travis/miniconda2/envs/statsmodels-test/lib/python2.7/site-packages/statsmodels-0.8.0-py2.7-linux-x86_64.egg/statsmodels/discrete/discrete_model.py", line 3028, in summary2
    confint[i])
  File "/home/travis/miniconda2/envs/statsmodels-test/lib/python2.7/site-packages/statsmodels-0.8.0-py2.7-linux-x86_64.egg/statsmodels/iolib/summary2.py", line 339, in summary_params
    data = np.hstack([data, conf_int])
  File "/home/travis/miniconda2/envs/statsmodels-test/lib/python2.7/site-packages/numpy/core/shape_base.py", line 277, in hstack
    return _nx.concatenate(arrs, 1)
ValueError: all the input array dimensions except for the concatenation axis must match exactly

Digging into this, it looks like we're trying to concatenate arrays with shapes (6,6,4) and (6,6,2), respectively. So we can make a little bit of progress by replacing np.hstackwith np.concatenate(arrs, 2). But in the next line we try to wrap the result in a DataFrame, which breaks because it is 3D. I think the underlying issue is that summary_params doesn't play nicely with two-dimensional params.

This is a design-decision issue. I don't actually use this model often enough to have an opinion.

@josef-pkt

Copy link
Copy Markdown
Member

@jbrockmendel It would be better to keep Multinomial bugfixes and cleanup CLN commits in separate PRs, so they can be separately merged

for a quick overview of commit list, starting with CLN <modulename> ... would be more informative.
commit messages should start with a commit code http://www.statsmodels.org/devel/dev/maintainer_notes.html#commit-comments
(not fully or exactly enforced conventions)

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

I'll look through those notes and try to adapt some more grown-up habits. This time around I wanted to get the bug documented before getting distracted. I'll open up a new issue specifically for that and close this PR.

@josef-pkt

Copy link
Copy Markdown
Member

another tool to practice after getting over the initial getting familiar with git hurdle is interactive rebase, git rebase -i ... to clean up the commit history in a PR.
As usual with git commands it takes some time to figure it out sufficiently, but then it's very useful.

@jbrockmendel
jbrockmendel deleted the ruthless_deletion branch June 2, 2017 02:46
@bashtage bashtage added the rejected Used for PRs with changes that are not acceptable label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected Used for PRs with changes that are not acceptable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants