---
title: "Analysis Lag"
method: POST
path: "/api/v1/analysis/lag"
tags: ["analysis"]
---

# Analysis Lag

`POST /api/v1/analysis/lag`

## Request

- Base URL: `https://api.cohearence.app` (the document declares no server; this is the origin it was published from)
- URL: `https://api.cohearence.app/api/v1/analysis/lag`
- Auth: HTTP bearer

Lagged correlation between two metrics: r/p/q/n across a window of lags.

**Pro only** (402 for free plans), alongside the rest of the Signal surface. A free
caller has no way to name a pair here anyway: the outline they get from
``/analysis/ecosystem`` carries opaque indices, not metric ids.

For each lag *L* in ``[-max_lag, +max_lag]`` (in resample buckets), metric_b
is shifted by *L* and correlated with metric_a over the overlapping points. A
positive lag means changes in metric_b tend to *follow* metric_a — temporal
precedence, not proof of causation.

Two guards against the profile's multiple-comparisons problem (up to 61
correlated tests whose tallest bar the UI invites the user to read off):

- each ``p`` is corrected for autocorrelation via Bartlett's effective
  sample size ``n_eff = n·(1−ρ₁ρ₂)/(1+ρ₁ρ₂)`` (daily health series are
  strongly AR(1), which makes raw p wildly anti-conservative), and
- ``q`` is Benjamini–Hochberg across the lag family, so the client can
  emphasize only lags with q ≤ 0.05 and render the rest as context.

``resample="None"`` is rejected: a row-shift over irregular raw timestamps
is not a time shift, so lags are only meaningful on a regular grid.

## Request body

- object

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/cohearence/apis/health-agent-api.md) · [All operations](https://skmtc.dev/cohearence/apis/health-agent-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cohearence/apis/health-agent-api/revisions/c7aee7d6ecf0?raw)
