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: Re-create OLS model using _init_keys #1957

Closed
kshedden opened this issue Sep 14, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@kshedden
Copy link
Contributor

commented Sep 14, 2014

I'm having trouble creating a derived model from an existing OLS model using _init_keys (needed for implementing a generic elastic_net).

The issue seems to be that OLS.__init__ calls the parent GLS.__init__, which has a 'weights' keyword argument. "weights" then gets added to _init_keys. But OLS.__init__ has no "weights" and no kwargs either, so when I do something like model.__class__(endog, new_exog, **model._init_keys) on an existing OLS instance, I get a type error about the unrecognized weights argument.

It may be a simple matter of adding **kwargs to OLS.__init__ and GLS.__init__.

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Sep 14, 2014

I think it's better to clean up the _init_keys to reflect the correct keywords for OLS

In OLS.__init__ after the super call, we can add
self._init_keys.pop('weights', None)
which should remove weights if it's there, and wouldn't cause an exception if it's not there

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Sep 18, 2014

_init_keys is a list and not a dictionary, see usage of remove instead of pop in #1959

@josef-pkt josef-pkt closed this in ea554cc Sep 18, 2014

@josef-pkt

This comment has been minimized.

Copy link
Member

commented Sep 18, 2014

@kshedden merged directly into master. You can delete this branch

Thanks

bashtage pushed a commit to bashtage/statsmodels that referenced this issue Sep 20, 2014

Merge branch 'OLS_init_keys_1959'
BUG: remove extra weights in _init_keys, closes statsmodels#1957
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.