# Augmented Dickey-Fuller

`D09-F01-A03` · Statistical Time Series → Diagnostics · archetype `record-transform` · difficulty 3/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/statistical-time-series/diagnostics/augmented-dickey-fuller/
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 { adf } from "fintech-algorithms/statistical-time-series/diagnostics/augmented-dickey-fuller";
```

## Signature

```ts
adf(values, lags, criticalValue)
```

Tests for a unit root. The null is that the series *has* one — so failing to reject is not evidence of stationarity, merely absence of evidence against a unit root. That asymmetry is the most misread thing in applied time series.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `number[]` | yes | Observation series in chronological order, oldest first. |
| `lags` | `number` | yes | Number of lagged differences included to absorb serial correlation. · min: 0, integer: true |
| `criticalValue` | `number` | yes | Critical value to compare the statistic against, at the chosen significance level. |

## Returns

`{ method, variant, nobs, lags, gamma, gamma_standard_error, statistic, decision, … }`

The statistic, the coefficient and its standard error, and an explicit decision — so the conclusion is separable from the arithmetic.

## Errors

- When the sample is too short for the requested lag order — throws

## Complexity

Time `O(n × lags²)`, space `O(n)`.

## 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

`values`:

```json
[0.49366418, 1.54242291, -0.82556495, 0.47513288, 0.50704417, -0.3816439]
```

Showing 6 of 96 elements.

`lags`:

```json
1
```

`criticalValue`:

```json
-2.86
```

### Call

```ts
adf(values, lags, criticalValue)
```

### Returns

object with 15 fields: method, variant, nobs, regression_nobs, lags, gamma, gamma_standard_error, statistic, …

```json
{
  "method": "adf",
  "variant": "constant-only-fixed-lag",
  "nobs": 96,
  "regression_nobs": 94,
  "lags": 1,
  "gamma": -0.3307327402574888,
  "gamma_standard_error": 0.08555486242368153,
  "statistic": -3.8657386721007945,
  "critical_value": -2.86,
  "reject_null": true,
  "state": "reject-unit-root",
  "reason": "statistic-below-boundary",
  "coefficients": [0.09192051133561, -0.3307327402574888, -0.0052913498392460345],
  "residual_sse": 84.25503279621253
}
```

Showing 14 of 15 fields.

## Other exports

`acf`, `pacf`, `kpss`, `ljungBox`, `zivotAndrews`, `runDiagnostic`. 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/diagnostics/augmented-dickey-fuller/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/statistical-time-series/diagnostics/augmented-dickey-fuller/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
