Correlate two series
correlate_metric_seriesCompute Pearson correlation between two daily metric series on overlapping recorded days, with an optional lag to test lead-lag relationships.
Instructions
Pearson r between two daily series, over days that have BOTH recorded.
lag_days pairs series_a on each day with series_b that many days
LATER (negative = earlier): "does a short night show up in HRV the day
after" is sleep vs HRV with lag_days=1. Sleep is already dated by the
morning it ends, so lag 0 is "last night vs today". since / until
("YYYY-MM-DD") restrict to a calendar window.
Days missing on either side are dropped, never interpolated and never read as
zero, so n_pairs is usually smaller than either series — quote it with r.
Fewer than 3 shared days returns null with a reason: any two points are
perfectly collinear, so a coefficient there is an artefact.
The result carries a caveat field about causation. Repeat its substance in
your answer, and do not translate r into a word like "strong".
Carries a coverage block over the days the arithmetic used: quote
coverage.days_covered and coverage.span_days beside any number here.
coverage.window_satisfied: false alone does NOT mean a short history — it is
also false when older days exist beyond the window; coverage.more_available
tells the two apart.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | ||
| fresh | No | ||
| since | No | ||
| until | No | ||
| partner | No | ||
| lag_days | No | ||
| series_a | Yes | ||
| series_b | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||