Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
josef-pkt opened this issue Apr 26, 2024 · 0 comments
Open

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

josef-pkt opened this issue Apr 26, 2024 · 0 comments

Comments

@josef-pkt
Copy link
Member

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

josef-pkt added a commit to josef-pkt/statsmodels that referenced this issue Apr 26, 2024
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

No branches or pull requests

1 participant