fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

ARMA

Install and import#

bash
npm install fintech-algorithms
ts
import { forecastARMA } from "fintech-algorithms/statistical-time-series/forecast-models/arma";

Signature#

forecastARMA(values, ar, ma, intercept, horizon)

ARMA forecasting with supplied coefficients: autoregressive terms on past values, moving-average terms on past errors.

Parameters#

NameTypeNotes
valuesnumber[]Observation series in chronological order, oldest first.
arnumber[]Autoregressive coefficients.
manumber[]Moving-average coefficients applied to past forecast errors.
interceptnumberConstant term.
horizonnumberSteps ahead.
min: 1 · integer: true

Returns#

{ forecast, fitted, residuals, state }

Forecasts, fitted values and residuals.

Errors#

  • When the sample is shorter than the model order — throws

Complexity: time O(n × (p + q)), space O(n).

Worked example#

verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

Input#

values
[10, 12, 11]
ar
[0.5]
ma
[0.25]
intercept
5
horizon
2

Call#

forecastARMA(values, ar, ma, intercept, horizon)

Returns#

object with 1 field: forecast

{
  "forecast": [10.375, 10.1875]
}

Diagrams#

ARMA — boundary failure
ARMA — diagnostic workbench
ARMA — family handoff
ARMA — forecast origin
ARMA — recursion anatomy

Calculation flow#

ARMA Calculation Flow
flowchart LR
    A["Finalized equally spaced training series"] --> B["Validate cutoff and frozen parameters"]
    B --> C["Build selected state or transformed series"]
    C --> D["Calculate horizon h conditional mean"]
    D --> E{"More horizons?"}
    E -- "yes" --> F["Append forecast and zero future innovation"]
    F --> D
    E -- "no" --> G["Publish path and state trace"]
    G --> H["Reveal holdout only for evaluation"]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Forecast Models family#