Repository navigation
Conversation
|
Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-01-06 18:20:39 UTC |
|
This pull request introduces 25 alerts and fixes 1 when merging 6bf62bc into 79c61b3 - view on LGTM.com new alerts:
fixed alerts:
|
|
amended first commit with pep-8 cleaning and force pushed |
|
This pull request introduces 24 alerts and fixes 1 when merging 0f9ca0e into 79c61b3 - view on LGTM.com new alerts:
fixed alerts:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6268 +/- ##
==========================================
+ Coverage 84.56% 84.97% +0.41%
==========================================
Files 643 642 -1
Lines 101188 103635 +2447
Branches 11104 11326 +222
==========================================
+ Hits 85568 88069 +2501
+ Misses 13173 13074 -99
- Partials 2447 2492 +45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| only case endog_idx=-1 | ||
| ''' | ||
| rr = self.rs_current | ||
| return (rr[-1, :-1] / np.diag(rr)[:-1, None]) |
There was a problem hiding this comment.
this computes for all variables except endog at index -1
It is not restricted to variables that are not yet in exog. (If we sweep an already swept variable, then we reverse the sweep, according to some references.)
I think this is 2-dim, how all parameters change for sweeping each variable.
columns are parmeters for a single regression
rows are the variables that are swept
|
AFAICS, there is currently no easy way to clone a StepwiseOLSSweep instance it is designed for stepwise regression where we go forwards (or backwards when that works), but we only keep hold of one instance. We evaluate candidate sweeps with params_new and rss_diff which don't need a new instance. However, if we want all-subsets regression, or best-subsets regression, then the structure of models to evaluate is tree like and we need to go down different or all branches from a subroot. In this case, we need to hold on to the subroot case while evaluated a branch. One likely possibility: Create a Sweep class that uses only minimum information, e.g. product or moment matrix, xy.T @ xy, or sweep matrix and either add |
|
current limitation in StepwiseOLSSweep sweep algorithm is generic for multivariate exog, but results statistics are only for a single endog assumed to be in the last column and row of the product and sweep matrix. In general we would have 3 sets, included exog, not yet included exog and endog |
|
downdating, i.e. dropping variables, works by just sweeping and already swept variable
|
|
still bug in untested methods, e.g. however, it looks like we can look at adding and dropping variables at the same time in equivalent to ols results
|
|
pattern for add and drop, Some of those are the same computations as a sweep but only for smaller parts of the sweep matrix, mainly related to endog column. That's still computationally more efficient than several full sweeps from the same starting matrix. This would make it easy to evaluate 1-step changes to the set of included exog. |
|
Darlington has a description for how to compute all subset regression in 2**k sweeps Floating point noise will accumulate with a large number of sweeps. |
|
parameters of interest and exog that are always included StepwiseOLSSweep has a delta df_model option needs example and unit tests We want a similar option for all subset regression, i.e. absorb variables of interest and then do the all subset regression using aic or similar with corrected Ultrahigh screening includes the never to penalize or unselect variables of interest directly instead of absorbing them. extension: do all subset sweep only on part of exog, e.g. a block of columns somewhere in the middle between exog_keep and endog in the xy sweep matrix. invalid models |
|
more ideas to support use cases for sweeping #6237 model averaging, model selection uncertainty and sensitivity to specification suppose we have some parameters of interest and many confounders If we use the full sweep matrix for an all subset or another large sweep of the confounders, then we should also store the parameters of interest for every sweep or model. We need options about what to store and whether to make storing extra attributes conditional on some "goodness" criterion. alternative way of blocking (maybe not, currently endog in last column is hard coded) |
|
now with an all subset regression function, adding aside for keeping results: Sensitivity plots in example I have seen for #6223 include confidence interval of the parameter of interest for each model. Currently I'm not keeping enough information from the sweeped models to be able to compute conf_int. conf_int are also not yet available in |
|
This pull request introduces 24 alerts and fixes 1 when merging f961dd6 into 79c61b3 - view on LGTM.com new alerts:
fixed alerts:
|
|
an example notebook for current code https://gist.github.com/josef-pkt/330f21972556852e1b0fc04bd8b3a3fc |
|
Seems to be a lot of code that isn't used. Can some/all of the unused code be removed? |
Most of the code should be used or have unit tests by the time I'm finished. Some might find use later. (I haven't looked enough at sequential QR again to see if this is the version I want. I think I wanted something different now, but related code will be useful for graph-lasso type models, i.e. sparse or penalized inverse covariance matrices.) |
|
moved to 0.14 main problem is that I didn't work on |
|
I ran into this by chance quick try: main part of SequentialQR seems to work as intended update |
|
I finally remembered more about SequentialOLSQR It cannot be used to estimate sequential parameters, that's why I ignored it in my last round here. The intention and usecase for it was variable selection where we have a predefined sequence of variables. The QR works for computing partial sum of squares which is all we need to compute llf and information criteria. |
|
There are still several mistakes, unfinished parts in Sequential e.g. normalized covparams corrected versions for the full model I don't know if we can easily get bse, or at least bse and tvalue for the last parameter of each submodel in the sequence. Another aside, but for the future: This also looks like we can get some sequential effectsize measure, eta, ... Related: we compute pacf in a similar way.
extension: |
|
update because of the triangular structure of R, invers of R is sequential i.e previous blocks remain unchanged when adding a variable the following produces a sequence of normalized cov_params and getting the normalized variance for the last parameter is also easy, e.g. one np.einsum of From there we should have then everything I wanted. |
this should add stepwise regression, sweep algorithm and sequential OLS
see #1809
currently it is mainly a script I wrote in 2012 converted to a module and two unit tests
also related to
PR #2380 multicollinearity properties of inverse covariance, and
PR #6265 for updating and downdating inverse covariance matrices
one submatrix of the sweep matrix contains the inverse product matrix and is updated similarly to #6265