Skip to content

WIP/ENH Robust nonlinear rebased - #9431

Open
josef-pkt wants to merge 6 commits into
statsmodels:mainfrom
josef-pkt:robust_nonlinear_rebased
Open

josef-pkt wants to merge 6 commits into
statsmodels:mainfrom
josef-pkt:robust_nonlinear_rebased

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

continuation of #3261

current state, it works but is a design mess

It is difficult to handle joint estimation of mean and scale in the same model as estimating mean with fixed or auxiliary scale (as in RLM)

more refactoring should separate into 2 types of models:

  • robust_nonlinear model (RNLM) with the same pattern as RLM, i.e. fixed or auxiliary scale, summary table and inference only for mean parameters
  • joint optimization of mean parameters and scale with possibly different basic objective functions (additionally modified by norms)
  • resistant estimators based on RNLM (e.g. S-, MM-estimators), should work with same pattern as now for RLM

using global estimators

  • works for RNLM
  • does not work for Huber-Dutter (scale =0 is a min)
  • might work for other joint objective functions
  • might be possible to use for S-estimator with scale as objective function. (not yet tried out)

@pep8speaks

pep8speaks commented Nov 21, 2024 •

Copy link
Copy Markdown

Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-11-21 16:23:22 UTC

p = np.concatenate((params_loc, s))
return self.loglikeobs(p)

import statsmodels.tools.numdiff as nd

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from'

Module 'statsmodels.tools.numdiff' is imported with both 'import' and 'import from'.
Comment on lines +103 to +105
# if isinstance(self.norm, rnorms.TukeyBiweight):
# # hardcoded for default shape/tuning parameter
# self.scale_fac = 3.97913

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
# note: extra scale cancels between nominator and denominator

if self.scale_fixed is None:
def func(s):

Check notice

Code scanning / CodeQL

Unused local variable

Variable func is not used.
Comment on lines +242 to +244
self.scale_fac = stats.norm.expect(
lambda t: t * self.norm.psi(t)
)

Check warning

Code scanning / CodeQL

Overwriting attribute in super-class or sub-class

Assignment overwrites attribute scale_fac, which was previously defined in superclass [MEstimatorHD](1).

def _predict_jac(self, params, exog=None):
if exog is None:
exog = self.exog

Check notice

Code scanning / CodeQL

Unused local variable

Variable exog is not used.

def predict_deriv(self, params, exog=None):
if exog is None:
exog = self.exog

Check notice

Code scanning / CodeQL

Unused local variable

Variable exog is not used.

def predict_deriv(self, params, exog=None):
if exog is None:
exog = self.exog

Check notice

Code scanning / CodeQL

Unused local variable

Variable exog is not used.
@josef-pkt
josef-pkt force-pushed the robust_nonlinear_rebased branch from 9bddd99 to 3abef6b Compare November 21, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants