Skip to content

ENH: Add recursive least squares model - #2830

Merged
ChadFulton merged 13 commits into
statsmodels:masterfrom
ChadFulton:ss-rls
Jun 13, 2016
Merged

ChadFulton merged 13 commits into
statsmodels:masterfrom
ChadFulton:ss-rls

Conversation

@ChadFulton

Copy link
Copy Markdown
Member

Closes #2759.

This adds a recursive least squares model at statsmodels.regression.rls, where computations are handled by the Kalman filter. In addition to the recursive coefficient estimates, it includes CUSUM and CUSUM of squares statistics and diagnostic plots.

See the example notebook rendered here: http://nbviewer.jupyter.org/gist/ChadFulton/7a63fbfca03276a04f2a

@josef-pkt

Copy link
Copy Markdown
Member

very good, cusum test is somewhere in diagnostic breaks_xxx (confidence bounds compared to GRETL, IIRC)

try to find longer names rls is robust least squares, restricted least squares, random least squares, ...

(IIRC, we have RLS for restricted least squares in a PR, but I'm using constrained now instead of restricted as general naming convention.)

@ChadFulton

Copy link
Copy Markdown
Member Author

How about statsmodels.regression.recursive_ls and class RecursiveLS?

I have unit tests against the existing CUSUM breaks_ functions.

@josef-pkt

Copy link
Copy Markdown
Member

names with recursive sound good.

(I might not be able to review very soon because I got stuck in sandwiches. sticky exposure :)

@ChadFulton

Copy link
Copy Markdown
Member Author

No problem on whenever it's convenient to review; thanks.

@ChadFulton

Copy link
Copy Markdown
Member Author

One thing I wanted to mention is that presumably this would be a model where allowing the formula interface would make sense, but I don't know much about getting that working.

@josef-pkt

Copy link
Copy Markdown
Member

just try out from_formula in the same way as in OLS.
Because your class has a standard __init__ signature, everything might/should just work automatically by inheritance.

RecursiveLS.from_formula(formula, data)....

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.08%) to 85.339% when pulling 98c82b7 on ChadFulton:ss-rls into b77e1a2 on statsmodels:master.

Comment thread statsmodels/regression/recursive_ls.py Outdated
return out

@cache_readonly
def recursive_resid(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postfix naming
resid_recursive

@josef-pkt

Copy link
Copy Markdown
Member

quick browse again.

The only change I see is to change the name of resid_recursive.

Inference on parameters, standard errors, wald tests, ... are currently not available, AFAICS, are they?
If not, then a comment or note in the docstring would be useful.

@ChadFulton Given that we haven't received any feedback by potential users, I would merge this as is. We expand it in future when we get feedback or find our own additional uses.
The way it is right now it's useful also for stability checks.

@josef-pkt josef-pkt added this to the 0.8 milestone Jun 12, 2016
@ChadFulton

Copy link
Copy Markdown
Member Author

Inference on parameters, standard errors, wald tests, ... are currently not available, AFAICS, are they?
If not, then a comment or note in the docstring would be useful.

Inference on the final recursive parameters is available as usual (the Results object is populated with the parameters and standard errors from the final estimates at the end of the sample); unless I've misunderstood your point?

@ChadFulton

Copy link
Copy Markdown
Member Author

Assuming all comes back green I will aim to merge this evening, unless something else comes up.

@josef-pkt

Copy link
Copy Markdown
Member

Inference on the final recursive parameters is available

good, I was thinking of multivariate estimation problems where we would want to have inference for all estimated parameters, not just the final. (I don't know if there is a usecase for those.)

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.08%) to 85.292% when pulling af64d1f on ChadFulton:ss-rls into 41a707a on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.08%) to 85.292% when pulling af64d1f on ChadFulton:ss-rls into 41a707a on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.08%) to 85.292% when pulling af64d1f on ChadFulton:ss-rls into 41a707a on statsmodels:master.

@ChadFulton

Copy link
Copy Markdown
Member Author

If Travis and Coveralls come back green, I will merge.

@ChadFulton

Copy link
Copy Markdown
Member Author

Reminder on the BDS test reminded me that before I merge I need to add to release notes.

@josef-pkt

Copy link
Copy Markdown
Member

@ChadFulton You could add to the release notes after merging this

I just opened the PR with my branch that creates the release file
https://github.com/statsmodels/statsmodels/pull/3005/files
I will look at it and merge it tomorrow.

there are also statespace models that need some more description
I was trying to track the status of 0.8 in #2176

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) to 85.44% when pulling bf1a2ca on ChadFulton:ss-rls into 41a707a on statsmodels:master.

@ChadFulton

Copy link
Copy Markdown
Member Author

Okay, I'll add to the release notes for 0.8 when they're merged.

@ChadFulton
ChadFulton merged commit a66a1e3 into statsmodels:master Jun 13, 2016
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) to 85.44% when pulling 9fa8be1 on ChadFulton:ss-rls into 41a707a on statsmodels:master.

@ChadFulton
ChadFulton deleted the ss-rls branch June 13, 2016 16:31
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