arima: implement bootstrap prediction intervals in forecast_arima - #1207
Open
Coro (AlejandroCoronadoN) wants to merge 1 commit into
Open
Coro (AlejandroCoronadoN) wants to merge 1 commit into
Coro (AlejandroCoronadoN) wants to merge 1 commit into
Conversation
forecast_arima(bootstrap=True) raised NotImplementedError despite the bootstrap simulation infra already existing. Wire simulate_arima(error_distribution= "bootstrap") so it produces empirical prediction intervals: simulate npaths future paths by resampling the in-sample residuals and take empirical quantiles. Adds a regression test. Addresses Nixtla#1191 (ARIMA part).
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
forecast_arima(..., bootstrap=True)raisedNotImplementedError("bootstrap=True"), eventhough the bootstrap simulation infrastructure already exists
(
simulate_arima(..., error_distribution="bootstrap"), which resamples the in-sampleresiduals). This PR wires that infrastructure in so
bootstrap=Trueproduces empiricalprediction intervals instead of raising. Addresses #1191 (the ARIMA part).
What it does
When
bootstrap=True, instead of the parametricpred ± q·seformula,forecast_arimanow simulates
npathsfuture sample paths by resampling the fitted residuals(
simulate_arima(..., error_distribution="bootstrap")) and takes the empirical quantilesfor each requested
level. This is the standard empirical/bootstrap prediction-intervalmethod (Hyndman & Athanasopoulos, Forecasting: Principles and Practice; the same approach
as R's
forecast::forecast(bootstrap=TRUE)), implemented natively with the library's ownsimulate_arima/sample_errors— no external code.Notes:
xreg(before the internal drift column is appended) is passed tosimulate_arima, which adds the drift term itself, so drift is not double-counted.ValueErroris raised if the fitted model does not store residuals.["80%", "95%"], etc.) match the parametric branch.Verification
test_forecast_arima_bootstrap_intervals: intervals are finite, bracket themean, and the 80% band sits inside the 95% band.
tests/test_arima.pytests still pass.ruff check/ruff formatclean on the changed lines.Follow-up
The issue also mentions the
bootstrapargument being unused in the ETS path(
pegelsfcast_C). Wiring bootstrap through the ETS interval computation (routing theanalytic classes through the existing simulation path) is more involved and left as a
follow-up so this PR stays focused on the ARIMA
NotImplementedError.