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/REF ? kwargs in RegressionModel.fit OLS, ... #8758

Open
josef-pkt opened this issue Mar 25, 2023 · 3 comments
Open

BUG/REF ? kwargs in RegressionModel.fit OLS, ... #8758

josef-pkt opened this issue Mar 25, 2023 · 3 comments

Comments

@josef-pkt
Copy link
Member

josef-pkt commented Mar 25, 2023

It looks like we can still have misspelled, incorrect keywords in fit of linear regression models.
https://stackoverflow.com/questions/75842157/results-summary-reporting-z-instead-of-t-value-for-multiple-ols-regression-using

Any kwargs are just added as attributes to the results instance.

I don't know or don't remember what this is used for, maybe some subclasses use it.

If subclasses use it, then we have to make up a list of allowed keywords similar to what I did for __init__ in models.

@josef-pkt
Copy link
Member Author

The kwargs have been added 13 years ago, but I don't see a specific reason
b6eaa4c#diff-4038c404a4188bbadc3f50dd9db62c486e4806cacda9df176ea7e8a2b53388f0

@josef-pkt
Copy link
Member Author

unit test fails if I raise a ValueError if kwargs in

FAILED ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_gretl.py::TestGLSARGretl::test_all
FAILED ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_gretl.py::test_GLSARlag
FAILED ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_regression.py::test_regularized_predict
ERROR ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_stata.py::TestGLSARCorc::test_params_table
ERROR ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_stata.py::TestGLSARCorc::test_predicted
ERROR ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_stata.py::TestGLSARCorc::test_rho
ERROR ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_stata.py::TestGLSARCorc::test_glsar_arima
ERROR ..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_glsar_stata.py::TestGLSARCorc::test_glsar_iter0

So we are using the kwargs.

example GLSAR.iterative_fit uses it to attach extra attributes to results instance

results = self.fit(history=history, **kwargs)

one possible solution is to add a more explicit results_kwds to fit

@josef-pkt
Copy link
Member Author

for fit_regularized unit test

It looks like the generic code always uses maxiter as fit keyword.
maxiter does not apply or do anything in OLS, WLS, and GLSAR uses maxiter only in iterative_fit

..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\tests\test_regression.py:1468:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\linear_model.py:848: in fit_regularized
    rslt = OLS(self.wendog, self.wexog).fit_regularized(
..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\regression\linear_model.py:1130: in fit_regularized
    return fit_elasticnet(self, method=method,
..\eclipse-workspace\statsmodels_gh\statsmodels\statsmodels\base\elastic_net.py:236: in fit_elasticnet
    rslt = model1.fit(maxiter=0)

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

No branches or pull requests

1 participant