---
title: "Analysis Regression"
method: POST
path: "/api/v1/analysis/regression"
tags: ["analysis"]
---

# Analysis Regression

`POST /api/v1/analysis/regression`

## 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/regression`
- Auth: HTTP bearer

Least-squares fit of ``metric_y`` on ``metric_x`` — the scatter + line view.

Fits an ordinary least-squares (OLS) straight line to the two metrics' aligned
daily series and returns everything the Analysis page's Regression section
draws and states:

- ``points``: the aligned (x, y) scatter cloud.
- ``fit.line``: the two-point OLS line; ``fit.lowess``: a locally-weighted
  smoother showing the data's actual shape (so curvature is visible next to
  the straight line); ``fit.fitted``/``fit.residuals``: the residual-vs-fitted
  diagnostic.
- ``fit``: slope, intercept, Pearson ``r``, **R²**, the slope's 95% CI, a
  robust **Theil–Sen** slope cross-check, the Spearman ``r`` + ``is_linear``
  linearity gate, and both the naive and autocorrelation-adjusted p-values.

``lag`` shifts the response relative to the predictor (positive = y follows x)
on the resample grid; ``resample="None"`` is rejected because a row shift over
irregular raw timestamps is not a time shift. Regression is asymmetric — x is
the predictor, y the response — so the pair order matters.

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