# ACF

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

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

## Signature

```ts
acf(values, maxLag)
```

Autocorrelation at each lag. The first diagnostic to run on any series you intend to model: it shows whether there is structure to model at all, and slow decay is the classic signature of non-stationarity.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `values` | `number[]` | yes | Observation series in chronological order, oldest first. |
| `maxLag` | `number` | yes | Highest lag to compute. Beyond roughly n/4 the estimates are too noisy to read. · min: 1, integer: true |

## Returns

`{ method, variant, nobs, max_lag, mean, denominator, numerators, coefficients, confidence_bands }`

Coefficients with the numerator and denominator used — estimators differ in whether the denominator varies with lag, and the two conventions give visibly different plots.

## Errors

- When maxLag is not less than the sample size — throws

## Complexity

Time `O(n × maxLag)`, space `O(maxLag)`.

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

`maxLag`:

```json
12
```

### Call

```ts
acf(values, maxLag)
```

### Returns

object with 11 fields: method, variant, nobs, max_lag, mean, denominator, numerators, coefficients, …

```json
{
  "method": "acf",
  "variant": "centered-unadjusted-direct",
  "nobs": 96,
  "max_lag": 12,
  "mean": 0.29779557927083333,
  "denominator": 153.9714722414195,
  "numerators": [
    153.9714722414195,
    102.29629606088473,
    67.86612357881646,
    43.864068660314665,
    13.159013573869158,
    -12.01222465335103
  ],
  "coefficients": [
    1,
    0.6643847368068891,
    0.4407707648102877,
    0.28488438813871975,
    0.08546397187939134,
    -0.07801591085987973
  ],
  "confidence_95": 0.2000416623272929,
  "state": "estimated",
  "reason": "finite centered series with nonzero variance"
}
```

## Other exports

`pacf`, `adf`, `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/acf/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/statistical-time-series/diagnostics/acf/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
