Skip to content

BUG/TST robust norms bugs and unit tests #8800

Closed

Description

@josef-pkt

Robust norms do not have their own unit tests. They are only indirectly tested through RLM results.

old PR #1341 included some fixes for Hampel bugs and shifted tukey biweight.
see also #8697 and #8696 for Hampel bugs

Methods of norms used in RLM

  • fit only uses weights
  • cov_params, bcov_scaled uses psi_deriv and psi
  • deviance uses rho (__call__)

unit tests possible against R robustbase
(in my old PR, I did not have reference numbers, I used mostly graphical inspection and checking formulas)

e.g.

> Mpsi(c(-9, -6, -2, -1, 0, 1, 2, 6, 9), cc = c(1.5, 3.5, 8), psi = "hampel")
[1]  0.0000000 -0.6666667 -1.5000000 -1.0000000  0.0000000  1.0000000  1.5000000
[8]  0.6666667  0.0000000
> Mpsi(c(-9, -6, -2, -1, 0, 1, 2, 6, 9), cc = c(1.5, 3.5, 8), psi = "hampel", deriv=-1)  # unscaled rho
[1] 7.500000 6.833333 1.875000 0.500000 0.000000 0.500000 1.875000 6.833333
[9] 7.500000

Activity

  1. added this to the 0.14 milestone on Apr 14, 2023
  2. josef-pkt commented on Apr 14, 2023

    @josef-pkt
    MemberAuthor

    RLM unit test for Hampel has bcov_scaled tol reduced from decimal_4 to decimal_3

    strange: codecov has only 3 lines in norms not covered by unit tests

    deviance, including dev as convergence criterion, does not have unit tests.
    update deviance is and always was the default convergence criterion. So it's called at every default fit.
    Convergence check only requires that convergence criterion does not change, so actual values are irrelevant.
    So, rho has full line coverage, but values are not checked.

  3. josef-pkt commented on Apr 14, 2023

    @josef-pkt
    MemberAuthor

    merging my old changes is very difficult because there are many changes in norms in main.

    Most look cosmetic or reformulations.
    Both hampel rho and negative part of psi still do not match R robust base.

    This needs unit tests first before changing the current code with specific corrections.

    However, hampel rho and psi in my old pr matches R robust base
    psi_deriv is wrong in statsmodels main and in my PR version, wrong sign at edges of hill

  4. josef-pkt commented on Apr 14, 2023

    @josef-pkt
    MemberAuthor

    @bashtage This should still go into 0.14
    I will finish a PR with bugfixes and unit tests for, at least, hampel and biweight.

    The additional bug in hampel psi_deriv could make cov_params more wrong than I previously thought.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions