Repository navigation
Heckman rebased - #7636
Heckman rebased#7636josef-pkt wants to merge 39 commits into
Conversation
…private methods, renamed fitted to results
… routines do more
…umpy regarding integer array casting
|
Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-08-11 00:44:26 UTC |
|
This pull request introduces 6 alerts when merging d025730 into 47137eb - view on LGTM.com new alerts:
|
d025730 to
81f3c74
Compare
|
there is still a python 2 compat left: and a lot of pep-8 pep-8 cleaning will add a lot of noise to history. |
|
This pull request introduces 6 alerts when merging 81f3c74 into 47137eb - view on LGTM.com new alerts:
|
|
test failure/error of statespace in LinuxTest python_37_legacy_blas |
| def loglike(self, params): | ||
| return self.loglikeobs(params).sum(axis=0) | ||
|
|
||
| def nloglike(self, params): |
There was a problem hiding this comment.
can be deleted. not used, I think
| kwds.setdefault('centered', True) | ||
| return approx_fprime(params, self.loglike, **kwds).ravel() | ||
|
|
||
| def jac(self, params, **kwds): |
There was a problem hiding this comment.
this is now named score_obs
There was a problem hiding this comment.
does it work with numdiff?
no unit test coverage
| exog = self.exog | ||
| return np.dot(exog, params) | ||
|
|
||
| if self._results is None and params is None: |
There was a problem hiding this comment.
parts here are not reached. can be deleted
I guess left over from an old pattern attaching _results to model
|
looks like all review comments in old PR #1935 have been resolved, code changed |
| return data | ||
|
|
||
|
|
||
| def get_datamats(self): |
There was a problem hiding this comment.
these can be added as attributes, no need for extra methods and repeated evaluation
81f3c74 to
45f4d27
Compare
|
This pull request introduces 6 alerts when merging 45f4d27 into 47137eb - view on LGTM.com new alerts:
|
| num_zvars = Z.shape[1] | ||
|
|
||
| xbeta = np.asarray(params_all[:num_xvars]) # reg eqn coefs | ||
| zbeta = np.asarray(params_all[num_xvars:num_xvars+num_zvars]) # selection eqn coefs |
There was a problem hiding this comment.
not good names
which is which?
(I just wanted to quickly check whether binary parameters are before the main model linear parameters)
| exog : array-like | ||
| Design / exogenous data | ||
| params : array-like, optional after fit has been called | ||
| Parameters of a linear model |
There was a problem hiding this comment.
params should be the full params
split up with names params_main, params_select
|
X, Y, Z need mostly be renamed, we can still use them as short cut aliases only inside formulas It's difficult to skim just pieces of code. Names are not self-explanatory. |
|
in params the main model params should be first |
|
too many small commit, partial squashing would be useful. test_heckman could use a refactoring, e.g. stata results are included in test module not in a results module |
|
I think I can squash all commits before "ENH: added log likelihood function for heckman". Those are all for 2-step AFAICS |
|
huge number of pep8 violation, line length and indentation. The results class has the results for the linear model, 2-step has probit results instance So, this is similar to IV (2SLS) estimation, where main I still don't know what would be a good structure #7903 |
|
llf for both 2-step and mle raises ValueError with shape mismatch in loglikeobs results params and cov_params do not match the underlying joint model, so many generic features will not work.
|
|
I'm giving up for now on deciding on a proper model, results structure for endogenous sample selection models. The main option for getting heckman in this PR merged is to merge it without changing the basic structure as preliminary version, that will eventually (hopefully) replaced by something that fits better into a generic or general framework/pattern. I think before going to endogenous sample selection, it will be easier to start with a continuous endogenous explanatory variables and control function approach, e.g. related to ivpoisson. For binary endogenous explanatory variables, starting with treatment effect might be easier (and I know more about it). |
|
Here's the notebook based on the unit test example |
|
I'm not sure whether to clean up the unit tests for pattern and style. That would be rewriting most of the test file. For the estimator and results pattern, I think now not to change it. |
rebased version of #1935
no merge conflicts
extra commit: update pandas usage
no other changes yet.