fintech-algorithms

Structural VAR

Install and import

bash
npm install fintech-algorithms
ts
import { fitRecursiveSVAR } from "fintech-algorithms/statistical-time-series/multivariate-systems/structural-var";

Signature

fitRecursiveSVAR(values, lags)

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
[
  [-1.4163056264, -0.7075620912],
  [-1.4144491277, -0.24959813],
  [-1.915874322, -0.31233481]
]

Showing 3 of 120 elements.

lags
1

Call

fitRecursiveSVAR(values, lags)

Returns

object with 14 fields: coefficients, intercept, sigma_u_mle, impact_matrix, structural_shocks, reconstructed_sigma_u, covariance_reconstruction_max_error, structural_shock_covariance_mle, …

{
  "coefficients": [
    [
      [0.555831819774, 0.20542641337],
      [-0.118628539474, 0.408179850969]
    ]
  ],
  "intercept": [-0.070907764383, -0.013615076949],
  "sigma_u_mle": [
    [0.726815513707, 0.33092608263],
    [0.33092608263, 0.420249111781]
  ],
  "impact_matrix": [
    [0.852534758064, 0],
    [0.388167261804, 0.519206402739]
  ],
  "structural_shocks": [
    [-0.482046841046, 0.138538488641],
    [-1.181766100244, 0.181219012332],
    [-0.473854258318, 0.066359023845]
  ],
  "reconstructed_sigma_u": [
    [0.726815513707, 0.33092608263],
    [0.33092608263, 0.420249111782]
  ],
  "covariance_reconstruction_max_error": 1e-12,
  "structural_shock_covariance_mle": [
    [1, -1e-12],
    [-1e-12, 0.999999999999]
  ],
  "structural_shock_identity_max_error": 1e-12,
  "ordering": [0, 1],
  "companion_spectral_radius": 0.501247229166,
  "stability_state": "stable",
  "state": "identified-recursively",
  "reason": "lower-cholesky-ordering"
}

Other exports

This module also exports companionMatrix, companionSpectralRadius, fitVAR, choleskyLower, fitVECMFixedBeta, movingAverageMatrices, impulseResponses, forecastErrorVarianceDecomposition. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams

Structural VAR — system map

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