-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
REF: get_distribution, return 1-d instead of column frozen distribution #8780
Conversation
no failures so far, which is surprising or insufficient unit test coverage in discrete_model only NegativeBinomial predict(which="prob") calls get_distribution, Poisson, GPP, NBP use the distribution directly So, only NegativeBinomial predict(which="prob") could be wrong because of the shape change in get_distribution (Now, I don't remember why I switched to column distribution if I didn't use it much internally in statsmodels.) two unit tests in discrete that call get_distribution: |
I think I will not add work on RegressionModel/Results get_distribution to this PR. This means adding results.get_prediction will not be so simple, unless it calls get_prediction, but that's overkill. We only need weights handling, not standard errors. The |
refactoring bug NegativeBinomial
I can fix this by reshaping y_values internally for which = "predict", but users will need to reshape if they want vectorized evaluation of distr methods, e.g. cdf at different values. |
something weird with deltacov if params has only one element this works
but using one column exog raises exception in get_prediction I'm in the middle of making some changes for which="prob", so no clean code or example. NB, NBP and GPP don't fail (they have one extra params, so len(params)=2), but one parameter NB-geometric fails in the same way. AFAIR, we don't have another get_prediction case that has multivariate prediction. |
likely reason for problem in DeltaCov with 1-element params approx_fprime returns 1d gradient if len(params) == 1
for len(params) = 2:
update I cannot do the same for NB geometric because it uses get_distribution for predict which="prob", and scipy frozen distributions do not have the "private" methods like If we want to use complex step derivatives for predict/get_prediction, then we cannot go through the "public" methods of scipy.distributions, i.e. we need to implement it without going through get_distribution. |
when I change the return of approx_fprime to skip the squeeze if len(params) is 1
then I get unit test failures (run only in test_conditional directly compares approx_fprime result with score
The truncated failure were a consequence that poisson had returned which= prob in the wrong shape (?) |
This PR now includes the fix for approx_fprime return shape. The PR should be fine now but I don't have a good overview of what other parts might be affected. |
Finally, main and pr are all green except for pre-testing |
#8723
This also warns now on invalid
__init__
kwargs in BetaModel closes #8779I changed the get_distribution in discrete to return 1-d instead of 2d.
Some unit tests might fail.They didn'tSome parts don't fail because they are written to handle both 1-d or one 2-d column returns, they work around current inconsistency in return shape.
Not decided yet:
Do we add an option
as_column=False
to get_distribution?Currently, I commented out the old column code, so I can reuse it if we add the option.
update not for now
Related missing:
GLM and OLS need results method (they only have model.get_distribution)