# Impulse-Response Analysis

`D09-F03-A04` · Statistical Time Series → Multivariate Systems · archetype `record-transform` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/statistical-time-series/multivariate-systems/impulse-response-analysis/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { impulseResponses } from "fintech-algorithms/statistical-time-series/multivariate-systems/impulse-response-analysis";
```

## Signature

```ts
impulseResponses(coefficients, horizon, impactMatrix)
```

Traces how a one-off shock to one variable propagates through the system over time. The headline output of any VAR — and only interpretable given the identifying assumption that produced the impact matrix.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `coefficients` | `number[][]` | yes | VAR coefficient matrices. |
| `horizon` | `number` | yes | Periods to trace. · min: 1, integer: true |
| `impactMatrix` | `Matrix` | no | Contemporaneous impact matrix. Defaults to the identity, so the responses are to unit shocks in each variable rather than to structurally identified ones. |

## Returns

`{ responses, cumulative_responses, horizon, impact_matrix, companion_spectral_radius, stability_state, … }`

Responses and their cumulative sums, plus the companion spectral radius — above 1 the system is explosive and the responses diverge rather than decay, which is stated instead of silently plotted.

## Errors

- When the coefficient matrices are not square or are inconsistent in dimension — throws

## Complexity

Time `O(horizon × k³)`, space `O(horizon × k²)`.

## Worked example

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

`coefficients`:

```json
[
  [
    [0.55, 0.18],
    [-0.12, 0.42]
  ]
]
```

`horizon`:

```json
8
```

`impactMatrix`:

```json
[
  [0.8, 0],
  [0.35, 0.55]
]
```

### Call

```ts
impulseResponses(coefficients, horizon, impactMatrix)
```

### Returns

object with 10 fields: responses, cumulative_responses, horizon, impact_matrix, companion_spectral_radius, stability_state, stability_boundary, near_boundary_threshold, …

```json
{
  "responses": [
    [
      [0.8, 0],
      [0.35, 0.55]
    ],
    [
      [0.503, 0.099],
      [0.051, 0.231]
    ],
    [
      [0.28583, 0.09603],
      [-0.03894, 0.08514]
    ]
  ],
  "cumulative_responses": [
    [
      [0.8, 0],
      [0.35, 0.55]
    ],
    [
      [1.303, 0.099],
      [0.401, 0.781]
    ],
    [
      [1.58883, 0.19503],
      [0.36206, 0.86614]
    ]
  ],
  "horizon": 8,
  "impact_matrix": [
    [0.8, 0],
    [0.35, 0.55]
  ],
  "companion_spectral_radius": 0.502593274925,
  "stability_state": "stable",
  "stability_boundary": 1,
  "near_boundary_threshold": 0.9,
  "state": "computed",
  "reason": "ma-recursion-times-declared-impact"
}
```

## Other exports

`companionMatrix`, `companionSpectralRadius`, `fitVAR`, `choleskyLower`, `fitRecursiveSVAR`, `fitVECMFixedBeta`, `movingAverageMatrices`, `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.

## Verification and provenance

Tier: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/statistical-time-series/multivariate-systems/impulse-response-analysis/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/statistical-time-series/multivariate-systems/impulse-response-analysis/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/statistical-time-series/llms.txt
