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
[ENH] Adds _predict_interval
to SARIMAX
to support predict_interval
and predict_quantiles
#4439
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, as usual!
Non-blocking comments:
- you should add yourself as an author
- the
_predict_interval
looks very similar to that in otherstatsmodels
functions. It might make sense to see whether the duplications (or partial duplications) can be refactored to live in a single place. I would consider that out of scope though for this PR, just making a note.
Regarding questions:
Yes, that would make sense.
I suppose that's the same comment I just made in the review? Fair enough, so what you're saying, there are subtle interface inconsistencies? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing I noticed, apologies for not letting you know first time round - I just fixed something similar as part of the pandas 2
compatibility patch.
lines 242, 243 look identical to lines in AutoETS
.
These cause a failure on pandas 2
which no longer allows to write to index locations that do not exist.
Could you kindly follow the fix in #4427 (AutoETS
) instead? (this replaces the offending lines by an alternative call that works on both pandas 1
and pandas 2
)
I also notice, the entire _predict_interval
looks identical, except the name of the method of prediction_results
which is called.
Could a refactor work by adding an attribute or tag to the adapter parent class which has the name of the attribute (string) and is looked up inside _predict_interval
? Or a private function with that as an argument, which is called from _predict_interval
?
Would appreciate an issue with any observations you might have on similarities and/or how to refactor this (if you don't get to it, I will open one later when I'm done with the pandas 2
upgrade)
Yes. For example, |
Well, but there are at least three instances where the similarities are very high, see above. (maybe we should move this discussion to a refactor issue, as it isn't really about #4439 anymore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's exactly what I meant!
… `statsmodels` based forecasters to reduce code duplication (#4465) Closes #4447. Depends on #4439 and #4452. The implementation of `_predict_interval` in `AutoETS`, `SARIMAX` and `UnobservedComponents` were very similar. This PR helps to define these at a single place at base level which should help maintaining easier. Observations on multivariate estimators as being discussed in #4447.
Reference Issues/PRs
Fixes #4301.
What does this implement/fix? Explain your changes.
Before this PR,
SARIMAX
did not support prediction of confidence intervals and quantiles. This PR adds those functionalities, and tests to check that results match with underlyingstatsmodels
estimator.Does your contribution introduce a new dependency? If yes, which one?
No.
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
Yes.
Any other comments?
SARIMAX
instatsmodels
has a boolean argumentsimple_differencing
. If it's set to beTrue
, the forecasts and predictions are about the differenced series. It can be considered to add handling of that, similar to howpmdarima
does it.SARIMAX
did return datetime index for me for the example in [BUG]DynamicFactor
returns incorrect index for probabilistic forecasts #4362, and the available methods seem different as well. So, skipped generalisation attempt as of now as suggested here.PR checklist
For all contributions
For new estimators