Skip to content

BUG: support model-aware RLM scale callbacks - #9968

Closed
deepakganesh78 wants to merge 2 commits into
statsmodels:mainfrom
deepakganesh78:fix-rlm-scale-callback-gh9171
Closed

deepakganesh78 wants to merge 2 commits into
statsmodels:mainfrom
deepakganesh78:fix-rlm-scale-callback-gh9171

Conversation

@deepakganesh78

Copy link
Copy Markdown

Summary

  • support callable RLM scale estimators accepting (model, resid)
  • preserve existing single-argument callback behavior and df correction
  • document the callback option and add regression coverage for both signatures

Validation

  • pytest statsmodels/robust/tests/test_rlm.py -q (137 passed, 14 skipped)
  • pytest statsmodels/robust/tests/test_scale.py -k huber -q (10 passed)
  • Ruff, flake8, isort, and git diff --check

Closes #9171

Allow callable scale estimators to accept the fitted model and residuals while preserving existing single-argument callback behavior.

Closes statsmodels#9171

Co-authored-by: Copilot <[email protected]>
@bashtage

bashtage commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Could you add a real-world use case for this as part of the test?

@bashtage bashtage left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs simplification.

parameters = inspect.signature(self.scale_est).parameters.values()
except (TypeError, ValueError):
parameters = ()
n_args = sum(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is far too complicated. Why can a standard try, except work? Also, if the callable signature was (resid, model) then one could have model be optional so that existing methods can be simplified.

@github-actions

Copy link
Copy Markdown

Thanks for the pull request! The AI Disclosure checklist item in the PR description hasn't been completed yet.

Per the AI Policy, please edit the PR description and check the box that applies: either "No AI tools were used" or "AI tools were used" (naming the tool(s) and how they were used).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG/ENH: broken code in RLM._scale_est, scale callback option is missing

2 participants