Skip to content

BUG: emplike weights.sum < 1, enforce sum close to 1 #1845

Open

Description

@josef-pkt

investigating #1316 and #1831

I'm not able to replicate the failures, it always converges for me.
However, checking el_test for different values, I also get weird/wrong results.

In one case weights are mostly zero
in other cases they sum is equal to one within numerical error.

>>> llr, pval, w, p = tt.res1.el_test(0.784, [2], ret_params=True)
>>> w.sum()
0.085400220469679738
>>> w
array([  4.86330832e-17,   7.35626704e-17,   4.71643799e-17,
         1.99456822e-17,   5.58759305e-17,   5.64207446e-17,
         5.00890999e-17,   4.38986001e-17,   4.75506879e-17,
         5.11990713e-17,   6.11848967e-17,   7.36822444e-17,
         8.40161017e-17,   8.04144292e-17,   3.74126620e-17,
         4.12366246e-17,   3.82284014e-17,   3.64449122e-17,
         3.26098741e-17,   3.38589133e-17,   8.54002205e-02])

my current script (I did many other things in interpreter directly)

import numpy as np
from scipy import linalg, stats

from statsmodels.regression.linear_model import OLS
from statsmodels.emplike.tests import test_regression as tr

tt = tr.TestRegressionNM()

print linalg.svdvals(tt.res1.model.exog)

sig = 0.05
r0 = stats.chi2.ppf(1 - sig, 1)

do_all = False
if do_all:
    llr_ = [([b] + list(tt.res1.el_test(b, [2]))) for b in np.linspace(0.6, 1.29, 31)]
    llr = np.array(llr_)

print tt.res1.el_test(0.784, [2])

llr, pval, w, p = tt.res1.el_test(0.784, [2], ret_params=True)
print w.sum()
llr, pval, w, p = tt.res1.el_test(0.8, [2], ret_params=True)
print w.sum()

Activity

  1. josef-pkt commented on Jul 25, 2014

    @josef-pkt
    MemberAuthor

    high priority for now, because we need to figure out what to do with the failing tests

  2. josef-pkt commented on Jul 27, 2014

    @josef-pkt
    MemberAuthor

    see also #1216

    also statsmodels.emplike.descriptive.modif_newton doesn't check for convergence

    in an example with w.sum() < 1, the gradient is zero, but it's at a corner with zero weight and very large eta.

  3. added this to the 0.10 milestone on Apr 17, 2018
  4. added
    type-bug-wrong
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-emplikeprio-hightype-bugtype-bug-wrong

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions