Fixes in ARIMA inits#401
Merged
Merged
Conversation
r-smooth is now published on conda-forge; switch the version and downloads badges from the `r` channel to `conda-forge`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Before: sim.es() and simulate.adam/om/omg (R) plus sim_es and ADAM.simulate (Python) started from the raw initial level, while the fitter walked (lagsModelMax - 1) trend steps forward across the seasonal head. On ETS(A,A,A) with lags=12 the first simulated obs lagged the first fitted obs by ~(m - 1) * trend (28.99 on AirPassengers). Now the C++ simulator applies the same refineHeadFwd walk the fitter does, and first-simulated / first-fitted agree to ~1e-12. Refactor the three duplicated headFillFwd blocks in adamCore.h (fit + omfitGeneral + reapply) into one shared refineHeadFwd helper called from all three plus the new simulate path. Drop the refineHead argument from adamCore::fit / ::reapply / ::omfitGeneral (and their R + Python callers); it was hard-coded TRUE at every live site — Python code even said so in comments. Keep refineHead on adamCore::simulate — the forecast-interval simulator in predict(interval="simulated") legitimately needs FALSE (feeds the fitted state tail, not a raw initialiser output). R suite: 440 pass / 0 fail. Python suite: 716 pass. ruff / mypy clean. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PRdQhv3c5fgxm7GaequJtv
Time reversal changes the drift of an integrated series by (-1)^(d+D), so backcasting must negate the constant during the backward pass whenever the total order of differencing is odd — the direct ARIMA analog of the ETS trend reversal (b -> -b). Previously the drift pushed the backward pass in the wrong direction, biasing backcast initial states of drifted models: on BJsales with ARIMA(0,1,1)+drift the constant now estimates at 0.419 (sample mean of differences 0.420, was 0.407) with improved likelihood, and the auto.adam BJsales selection improves AICc from 521.64 to 520.95 (ARIMA(2,1,2) with drift). Even-parity models (e.g. SARIMA (0,1,1)(0,1,1)[12] with constant, d+D=2) are unchanged by construction. Implementation: new public flipConstant field on adamCore (exposed via Rcpp .field and pybind11 def_readwrite), applied symmetrically with the trend reversal in fit() and reapply(). The parity is computed R-side (architector wrapper in adam.R, adam-ssarima.R, reapply.R) and Python-side (architector()); all other construction sites keep the default FALSE. Also: - adamProfileCreator (R + Python) now emits lagsModelMax extra cyclic "tail" columns after the sample — infrastructure for boundary work on the backward pass. dfDiscounterFit trims the table to the in-sample width before its forth-and-back doubling. - test_autoadam.R baseline re-pinned to the post-fix values. - Python _initialize_arima_states fallback aligned with R (mean of series, not mean of differences), mirroring utils-adam.R:742-746. A full "tail mirror" of the state profile around the last observation was prototyped on top of the tail columns and measured: no effect on long samples (boundary transient decays), marginally worse at the backcast fixed point, and optimizer-basin instability on short samples. Removed after measurement; only the flips act on the whole backward pass and survive. R suite: 440 pass / 0 fail. Python: 716 pass, ruff + mypy clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PRdQhv3c5fgxm7GaequJtv
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.
No description provided.