Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

HistoricAverage

chronax.models.HistoricAverage · inherits BaseForecaster

Historic Average forecasting in JAX. Forecast = mean of all historical observations. Native intervals: $\sigma_h = \sigma \cdot \sqrt{1 + 1/n}$.

Attribute Type Description
uses_exog bool Whether the model supports exogenous variables (False).
alias str Model name.
conformal_params ConformalIntervals or None Optional object to enable conformal interval computation.
model_ dict Dictionary storing fitted artifacts, e.g. mean, fitted values, sigma, n.

__init__(self, alias: str = "HistoricAverage", conformal_params: ConformalIntervals | None = None) -> None

Initializes the HistoricAverage model.

Parameter Type Default Description
alias str "HistoricAverage" (undocumented)
conformal_params ConformalIntervals \| None None (undocumented)

fit(self, y: jnp.ndarray, X: jnp.ndarray | None = None) -> Self

Fit the HistoricAverage model.

Computes the historical mean of the series, stores fitted values, residual standard deviation, and series length for use in predict(). If conformal_params is configured, conformity scores are cached.

Parameters:

Parameter Type Default Description
y jnp.ndarray - Clean time series of shape (t,).
X jnp.ndarray \| None None Exogenous variables (unused; included for API compatibility).

Returns: Self (the fitted forecaster; sets self.model_).

predict(self, h: int, X: jnp.ndarray | None = None, level: list[int] | None = None) -> dict

Generate h-step ahead forecasts using the fitted model.

All h forecasts equal the historical mean. Optionally adds prediction intervals using either native normal approximation or conformal method.

Parameters:

Parameter Type Default Description
h int - Forecast horizon (number of steps ahead).
X jnp.ndarray \| None None Exogenous variables (unused; included for API compatibility).
level list[int] \| None None Confidence levels (0-100) for prediction intervals, e.g. [80, 95]. If None, only point forecasts are returned.

Returns: dict Dictionary containing:

  • "mean": Point forecasts of shape (h,), all equal to the historical mean.
  • "lo-{l}" / "hi-{l}": Interval bounds for each level l (only present when level is not None).

predict_in_sample(self, level: list[int] | None = None) -> dict

Return in-sample fitted values from the last fit() call.

All fitted values equal the historical mean. Optionally adds prediction intervals around each fitted point using the normal approximation $\sigma_h = \sigma \cdot \sqrt{1 + 1/n}$.

Parameters:

Parameter Type Default Description
level list[int] \| None None Confidence levels (0-100) for fitted prediction intervals, e.g. [80, 95].

Returns: dict Dictionary containing:

  • "fitted": In-sample predictions of shape (t,).
  • "fitted-lo-{l}" / "fitted-hi-{l}": Fitted interval bounds for each level l (only present when level is not None).

forecast(self, y: jnp.ndarray, h: int, X: jnp.ndarray | None = None, X_future: jnp.ndarray | None = None, level: list[int] | None = None, fitted: bool = False) -> dict

Memory-efficient stateless fit+predict in one call.

Computes the historical mean of y and generates h-step ahead forecasts without storing any model state. Optionally returns in-sample fitted values and prediction intervals.

Parameters:

Parameter Type Default Description
y jnp.ndarray - Clean time series of shape (t,).
h int - Forecast horizon (number of steps ahead).
X jnp.ndarray \| None None In-sample exogenous variables (unused; included for API compatibility).
X_future jnp.ndarray \| None None Future exogenous variables (unused; included for API compatibility).
level list[int] \| None None Confidence levels (0-100) for prediction intervals, e.g. [80, 95].
fitted bool False Whether to include in-sample fitted values in the output.

Returns: dict Dictionary containing:

  • "mean": Point forecasts of shape (h,), all equal to the historical mean.
  • "fitted": In-sample fitted values of shape (t,) (only if fitted=True).
  • "lo-{l}" / "hi-{l}": Forecast interval bounds for each level l (only present when level is not None).
  • "fitted-lo-{l}" / "fitted-hi-{l}": Fitted interval bounds (only present when both fitted=True and level is not None).