-
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
SUMM/ENH: get_prediction across models #7833
Comments
related usecase: test for prediction with non-zero e.g. test/pvalue, diff and confint that average prob(y=0) is equal to observed relative frequency at zero |
current
recently added PoissonResults.get_prediction has no docstring |
example: Poisson prediction confint with endpoint transformation versus delta-method
|
great, The model in this example is ZeroInflatedPoisson with constant inflation
|
expected (relative) frequency "prob" also works, but we currently have no option to choose for which y=k to predict nor to limit those with an upper bound but 2-d case, e.g. predict prob without the mean(0) only works partially
|
more design choices We can use endpoint transformation conf_int in models that have a mean function that depends on only mean parameters even if there are extra params. That follows from the gradient that has zeros at the extra params. So it would be convenient to have the option to compute both endpoint transformation and delta method confints in one function or method. The main problem is that we need the nonlinear predict function in terms of One way to implement this is to go through dfamilies, i.e. we have a We could delegate to a version of The main practical difference between Also, we have to decide whether only predict which="mean" gets endpoint transformation are all monotonic function of a single Decision for now:
Aside: ZI has submodels, and we could delegate predict/confint for, e.g. prob-main and mean-main to the submodels |
And now: where do we add the methods?
current plans
standalone function and explicit methods with delegation look less fragile than a specific Mixin. (*) just an idea: residuals are a nonlinear function of params, so we should be able to compute confint for statistics of them. |
Also we should remove duplication in handling predict keywords, offset, exposure, ... That's still messy with several predict, get_distribution, ... methods. edit both Also, I haven't looked into pandas return and getting row index for get_prediction. |
For GenericLikelihood we need a flag to decide whether we can use endpoint transformation for predict if which="mean". |
unit testing for delta method based results Stata: Currently, I'm using unit tests mainly against other cases or methods that already exist in statsmodels and have their own unit tests. |
exog handling in _prediction.get_prediction_glm looks good. That part had several bug fixes for pandas support. genmod get_prediction has a few problems #7864 , but I think it can be used for a more general version. The only backwards incompatible refactoring is that I want to drop I guess I keep it for mean. |
usecase, example https://stackoverflow.com/questions/70038929/confidence-interval-of-probability-prediction-from-logistic-regression-with-inte get_prediction as a function of a continuous exog, for each level of a binary exog |
more design decisions: get_prediction Mixin class or separate functions to delegate to: next round is get_prediction for BetaReg. If we add more get_prediction_xxx #7899, then a Mixin would be better. ??? Also, to avoid code duplication, there is now a lot of indirection and delegation, especially for prediction with NonlinearDeltaCov. |
we also need example right now: diagnostic statistic based on two current average option in get_prediction only allows average over observation of a single statistic, e.g. That's similar to average risk ratio in the literature which is defined as ratio of averages, and not as average of ratios If we have a generic predict_nonlinear that takes user specified functions, then we could delegate to it in We could delegate to the generic Alternative option: |
get_prediction outside tsa
current:
regression._prediction
genmod._prediction
no
which
yet: get_prediction so far is only for mean, expectation of endog E(y | x)algorithm or method cases, all based on cov_params
genmod._prediction
no generic function yet
which
in multi-link and extra_params modelsFor monotonic functions and links, we need reusable get_prediction for linear prediction.
Reusable means both no code duplication and no recomputation. The latter would mean that we can have different monotonic predictions using the same linear get_prediction. However, get_prediction should be relatively cheap.
To check: there might be some overlap with
margins
(after theat
part, margins and predict_at add construction of exog_predict.related issues and comments:
TBC
cases to start with
which
in Poisson for monotonic, especiallywhich="prob"
which
in NBP (and GPP) for non-monotonic, multi-parameter models (using NonlinearDeltaCov)The text was updated successfully, but these errors were encountered: