fintech-algorithms

SARIMA/SARIMAX

Install and import

bash
npm install fintech-algorithms
ts
import { forecastSARIMAX } from "fintech-algorithms/statistical-time-series/forecast-models/sarima-sarimax";

Signature

forecastSARIMAX(values, exog, futureExog, beta, ar, ma, seasonalAr, seasonalMa, intercept, differenceOrder, seasonalDifferenceOrder, period, horizon)

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

values
[12, 15, 18, 21, 24, 27]

Showing 6 of 8 elements.

exog
[
  [1],
  [2],
  [3]
]

Showing 3 of 8 elements.

futureExog
[
  [9],
  [10]
]
beta
[2]
ar
[0.5]
ma
[]
seasonalAr
[0.25]
seasonalMa
[]
intercept
0
differenceOrder
1
seasonalDifferenceOrder
0
period
2
horizon
2

Call

forecastSARIMAX(values, exog, futureExog, beta, ar, ma, seasonalAr, seasonalMa, intercept, differenceOrder, seasonalDifferenceOrder, period, horizon)

Returns

object with 6 fields: forecast, fitted, residuals, state, transformed_forecast, residualized_forecast

{
  "forecast": [35.625, 38.0625],
  "fitted": [null, null, null, 0.625, 0.625, 0.625],
  "residuals": [0, 0, 0, 0.375, 0.375, 0.375],
  "state": {
    "order": [3, 0],
    "last_values": [1, 1, 1],
    "last_residuals": [0.375],
    "presample_innovations": "zero",
    "future_innovations": "zero conditional mean",
    "orders": {
      "nonseasonal": [1, 1, 0],
      "seasonal": [1, 0, 0, 2]
    },
    "combined_ar": [0.5, 0.25, -0.125],
    "combined_ma": [],
    "beta": [2]
  },
  "transformed_forecast": [0.625, 0.4375],
  "residualized_forecast": [17.625, 18.0625]
}

Diagrams

SARIMA/SARIMAX — boundary failure
SARIMA/SARIMAX — diagnostic workbench
SARIMA/SARIMAX — family handoff
SARIMA/SARIMAX — forecast origin
SARIMA/SARIMAX — recursion anatomy

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