Skip to content

unhandled 0 division in the denominator, line275 in robust_linear_model.py #5878

Closed

Description

@jasonlocal

Describe the bug

[A clear and concise description of what the bug is. This should explain why the current behaviour is a problem and why the expected output is a better solution.]

Code Sample, a copy-pastable example if possible

# Your code here that produces the bug
# This example should be self-contained, and so not rely on external data.
# It should run in a fresh ipython session, and so include all relevant imports.
Details

Note: As you can see, there are many issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates.

Note: Please be sure you are using the latest released version of statsmodels, or a recent build of master. If your problem has been fixed in an unreleased version, you might be able to use master until a new release occurs.

Note: If you are using a released version, have you verified that the bug exists in the master branch of this repository? It helps the limited resources if we know problems exist in the current master so that they do not need to check whether the code sample produces a bug in the next release.

If the issue has not been resolved, please file it in the issue tracker.

Expected Output

A clear and concise description of what you expected to happen.

Output of import statsmodels.api as sm; sm.show_versions()

Details

[paste the output of import statsmodels.api as sm; sm.show_versions() here below this line]

Activity

  1. jasonlocal commented on Jun 21, 2019

    @jasonlocal
    Author

    Describe the bug:
    In robust_linear_model.py, there is unhandled zero division on line 275, I've noticed that if I pass in a DataFrame with perfect linear model fit with 0 residual, then the program hangs and never finishes.

    See the following for my example DataFrame(['FCFSales', 'const']being endogenous, ['BNRMTE02] being exdogenous )

          FCFSales  const    BNRMTE02
    1919 -0.217126    1.0 -498.484443
    1992       NaN    1.0   42.849964
    2067 -0.217126    1.0 -331.402878
    2141 -0.217126    1.0   88.030700
    2216       NaN    1.0  315.760558
    2291 -0.217126    1.0  -81.354436
    2364 -0.217126    1.0  -73.195943
    2435       NaN    1.0 -105.151041
    2504 -0.217126    1.0    1.082872
    2575       NaN    1.0 -100.000000
    

    The program hangs with error message:
    /NImounts/NiNoSnapDev/medusa_egg_cache/27-3/s/statsmodels-0.8.0-py2.7-linux-x86_64.egg/statsmodels/robust/robust_linear_model.py:284: RuntimeWarning: divide by zero encountered in divide
    self.weights = self.M.weights(wls_results.resid/self.scale)
    /NImounts/NiNoSnapDev/medusa_egg_cache/27-3/s/statsmodels-0.8.0-py2.7-linux-x86_64.egg/statsmodels/robust/norms.py:190: RuntimeWarning: invalid value encountered in less_equal
    return np.less_equal(np.fabs(z), self.t)

  2. bashtage commented on Jun 21, 2019

    @bashtage
    Member

    FWIW You can edit posts, so could you edit the first one and use the code block (which is demarcated with triple ticks)?

  3. added 3 commits that reference this issue on Jul 17, 2019
    021e003
    5c3e3a7
    2a56dbb
  4. added this to the 0.11 milestone on Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions