Skip to content

BUG: RLM fit with start_params raises if only one parameter #9233

Closed

Description

@josef-pkt

if start_params = np.array([5]) one element, 1-dim array, then the squeeze removes the 1-dim which then raises exception in shape check

statsmodels_gh\statsmodels\statsmodels\robust\robust_linear_model.py in fit(self, maxiter, tol, scale_est, init, cov, update_scale, conv, start_params, start_scale)
    264         else:
    265             start_params = np.asarray(start_params, dtype=np.double).squeeze()
--> 266             if (start_params.shape[0] != self.exog.shape[1] or
    267                     start_params.ndim != 1):
    268                 raise ValueError('start_params must by a 1-d array with {} '

IndexError: tuple index out of range

I ran into this for the constant only regression for resistant estimators in #9227

I don't know why there is the squeeze.
If we want or need to keep the squeeze, then a fix is to add
start_params = np.atleast_1d(start_params),

I will fix it this way in my PR, where I need it now

Activity

  1. added a commit that references this issue on Apr 26, 2024
    a3e739a
  2. added a commit that references this issue on May 15, 2024
    4520796
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions