ArimaSurrogate

class flexops.surrogates.arima.ArimaSurrogate(spec: SurrogateSpec | dict)

Non-seasonal ARIMA/ARIMAX relationship with explicit innovations.

See the module docstring for the spec. With config.history the pre-horizon state it implies is fixed; without it (regression mode) that state starts at zero and is left free for in-model estimation.

A free parameter given without a value starts from these guesses: 0.0 for the intercept or drift, min(1.0, max_ar_coeff) for AR lags, and 1.0 for MA lags and exogenous coefficients.

config_model

alias of ArimaConfig

classmethod initial_guess(name: str, config: ArimaConfig) → float

Return a free parameter’s starting value (see the class docstring).

property input_variables: dict[str, str]

Return exogenous input names and declared units.

classmethod make_spec(*, order: tuple[int, int, int] | list[int], input_variables: dict[str, str], output_variables: dict[str, str], values: dict[str, float] | None = None, deterministic: Literal['intercept', 'drift'] | None = None, fixed: dict[str, bool] | None = None, history: dict[str, Any] | None = None, max_ar_coeff: float | None = None, provenance: dict[str, Any] | None = None) → SurrogateSpec

Return a validated ARIMA spec.

Parameters:
  • order – (p, d, q).

  • input_variables – {name: units} of each exogenous input, in order.

  • output_variables – {name: units} of the one output.

  • values – {parameter: value} by the names arima_parameter_names() gives. A free parameter may be left out to start from its initial guess.

  • deterministic – "intercept" (d=0), "drift" (d=1), or None for no constant term.

  • fixed – {parameter: False} for each parameter to leave free; every other parameter is fixed.

  • history – The pre-horizon state; None for regression mode.

  • max_ar_coeff – Optional bound on every AR coefficient’s magnitude.

  • provenance – Free-form fit metadata.

Returns:

The spec.

Raises:

FlexConfigError – If the result does not match the contract.

property order: tuple[int, int, int]

Return (p, d, q).

property output_variables: dict[str, str]

Return the single output name and declared units.

classmethod parameter_shapes(config: ArimaConfig) → dict[str, tuple]

Return the deterministic term, one per lag and one per input.

solved_history(block, target) → dict[str, Any]

Return the history a solve implies, without recording it.

The history begins with the max(p + d, q) initialization lags the block was built with (the solved values in regression mode), followed by the solved horizon’s disturbances and innovations, and starts at the horizon’s first point. Rebuilding the same horizon from it reproduces the same initial state; a later horizon starts from the solved values.

Parameters:
  • block – The block build() returned, after a solve.

  • target – The time-indexed output variable passed to build().

Returns:

A history mapping for config.

Raises:

FlexConfigError – If the block has values missing (it has not been solved).

update_state(block, target) → None

Rewrite config.history from the solved horizon.

See solved_history(). The spec then initializes the next horizon from the solve. Parameters are untouched; read them with read_spec().

Parameters:
  • block – The block build() returned, after a solve.

  • target – The time-indexed output variable passed to build().

Raises:

FlexConfigError – If the block has not been solved.