Skip to content

Fixes in ARIMA inits#401

Merged
config-i1 merged 3 commits into
ETS-initialisationfrom
master
Jul 11, 2026
Merged

Fixes in ARIMA inits#401
config-i1 merged 3 commits into
ETS-initialisationfrom
master

Conversation

@config-i1

Copy link
Copy Markdown
Collaborator

No description provided.

config-i1 and others added 3 commits July 10, 2026 15:37
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
@config-i1
config-i1 merged commit aef943b into ETS-initialisation Jul 11, 2026
1 of 4 checks passed
config-i1 added a commit that referenced this pull request Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant