Correlation Agents
Purpose
Correlation analysis answers a fundamental analytical question: do these metrics move together? The step computes Pearson correlation coefficients for every pair of numeric datasets and produces interpretations that translate statistical relationships into actionable observations.
This is decomposed into two agents because correlation analysis requires two fundamentally different capabilities:
- Data preparation -- real-world datasets contain mixed types, missing values, and misaligned indices; these must be cleaned before mathematical computation is valid
- Interpretation -- a coefficient of -0.82 requires contextual translation for it to inform decisions
Value Proposition
- Quantified relationships -- every cross-metric claim is backed by a computed coefficient, not speculation
- Cascade identification -- detects chain effects (e.g., stress -> sleep -> energy) that reveal high-leverage intervention points
- Data quality assurance -- the normalizer ensures mathematical validity before computation
- Actionable output -- the analysis agent produces specific next steps, not abstract observations
Two-Agent Architecture
- Normalizer -- extracts numeric values, drops invalid entries ("N/A", null), and aligns arrays by index to produce clean datasets suitable for mathematical correlation
- Compute (deterministic, not an agent) -- calculates Pearson correlation coefficients for all dataset pairs
- Analysis -- interprets coefficients in context, classifying relationship strength and direction, and producing actionable recommendations
The Normalizer Agent
Responsibilities
- Extract numeric values from mixed-type arrays
- Drop non-numeric entries while maintaining alignment across datasets
- Preserve dataset ordering
- Report normalization outcomes (values dropped, alignment changes)
Example Transformation
Input (heterogeneous):
{
"datasets": [
{ "id": "stress", "data": [3.5, 4.0, "N/A", 3.2, 4.5] },
{ "id": "sleep", "data": [7, 6, 5, 7, 5] }
]
}
Output (normalized):
{
"normalized": [
{ "id": "stress", "values": [3.5, 4.0, 3.2, 4.5], "dimensions": 1 },
{ "id": "sleep", "values": [7, 6, 7, 5], "dimensions": 1 }
],
"summary": "Extracted 2 series with 4 aligned values each (dropped 1 non-numeric)"
}
Technical Details
| Property | Value |
|---|---|
| Registry ID | reasoning-engine-correlation-normalizer-agent |
| Profile ID | correlation-tool-normalizer |
| Code | src/mastra/agents/reasoning-engine/correlation/normalizer.ts |
| Accessor | getCorrelationNormalizerAgent() |
The Analysis Agent
Responsibilities
Interprets computed correlation coefficients, classifies relationship strength, identifies cascade effects, and produces up to three actionable recommendations.
Interpretation Scale
| Coefficient (r) | Classification | Typical Interpretation |
|---|---|---|
| 0.7 to 1.0 | Strong positive | Metrics move together consistently |
| 0.4 to 0.7 | Moderate positive | Notable co-movement |
| 0.0 to 0.4 | Weak positive | Limited relationship |
| -0.4 to 0.0 | Weak negative | Slight inverse tendency |
| -0.7 to -0.4 | Moderate negative | Notable inverse co-movement |
| -1.0 to -0.7 | Strong negative | Strongly inverse -- improving one metric may improve the other |
Example Output
{
"summary": "Strong negative correlation (r=-0.82) between stress and sleep quality indicates that elevated stress significantly disrupts sleep. Energy shows strong positive correlation (r=0.71) with sleep quality.",
"insights": [
"Elevated stress days consistently correspond to reduced sleep quality",
"Improved sleep is a strong predictor of higher energy the following day",
"Addressing stress may produce cascading benefits: reduced stress -> improved sleep -> higher energy"
],
"nextSteps": [
"Monitor the impact of stress management interventions on sleep quality",
"Prioritize sleep hygiene practices during high-stress periods",
"Track energy levels as sleep quality improves to validate the cascade hypothesis"
]
}
Technical Details
| Property | Value |
|---|---|
| Registry ID | reasoning-engine-correlation-analysis-agent |
| Profile ID | correlation-tool-analysis |
| Code | src/mastra/agents/reasoning-engine/correlation/analysis.ts |
| Accessor | getCorrelationAnalysisAgent() |
Pipeline Position
The correlation step executes as Step 3. It requires a minimum of 2 numeric datasets to compute meaningful correlations. When only one metric is available, the orchestrator typically bypasses this step.