# Measure correlation

Shape / inspect

correlation or association matrix, contingency table

Page: <https://meridian.online/operations/measure-correlation>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

correlation of two columns

It reads the `orders` table the proofs share. Create it first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT round(corr(amount, order_id), 4) AS r, round(covar_samp(amount, order_id), 2) AS cov,
       round(corr(amount, amount * 2 + 1), 4) AS with_itself_scaled FROM orders;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT r BETWEEN -1 AND 1 AND with_itself_scaled = 1 AND r = 0.1683 FROM result)) THEN 'as expected' ELSE error('the correlation is out of range, or a column does not correlate 1 with a linear copy of itself') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## Variants

- Measure covariance: Compute the population or sample covariance of two numeric columns.
- [Cross-tabulate two columns](https://meridian.online/operations/measure-correlation/cross-tabulate-two-columns): Count the rows for each combination of values in two or more categorical columns, with association tests such as chi-square.
- [Build a correlation matrix](https://meridian.online/operations/measure-correlation/build-a-correlation-matrix): Correlate every pair of chosen columns at once, giving a matrix of coefficients, covariances or mutual information.
- Other association measures: Measure internal consistency across columns, or count how often each value follows another.
- Correlate two columns: Compute one correlation coefficient, Pearson or rank-based, between two numeric columns.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Alteryx Designer: [`Association Analysis`](https://help.alteryx.com/current/en/designer/tools/data-investigation/association-analysis-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Contingency Table`](https://help.alteryx.com/current/en/designer/tools/data-investigation/contingency-table-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Pearson Correlation`](https://help.alteryx.com/current/en/designer/tools/data-investigation/pearson-correlation-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Spearman Correlation`](https://help.alteryx.com/current/en/designer/tools/data-investigation/spearman-correlation-tool.html) (read 2026-09-27)
- Apache DataFusion: [`corr`](https://datafusion.apache.org/user-guide/sql/aggregate_functions.html) (read 2026-09-27)
- Apache DataFusion: [`covar_pop`](https://datafusion.apache.org/user-guide/sql/aggregate_functions.html) (read 2026-09-27)
- Apache DataFusion: [`covar_samp`](https://datafusion.apache.org/user-guide/sql/aggregate_functions.html) (read 2026-09-27)
- DuckDB: [`corr`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- DuckDB: [`covar_pop`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- DuckDB: [`covar_samp`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- AWS Glue: [`ColumnCorrelation`](https://docs.aws.amazon.com/glue/latest/dg/dqdl-rule-types.html) (read 2026-09-27)
- KNIME Analytics Platform: [`Cronbach Alpha`](https://api.hub.knime.com/nodes/*iFALu0VL45kWr1b1?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Crosstab`](https://api.hub.knime.com/nodes/*pNm03fXRSkMzHV8O?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Linear Correlation`](https://api.hub.knime.com/nodes/*0gFnKniNdXkr6DtW?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Rank Correlation`](https://api.hub.knime.com/nodes/*sC8qjjAYkSsMFjOc?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Standardized Cronbach Alpha`](https://api.hub.knime.com/nodes/*oE1zFiY4KVBa9S2x?details=full) (read 2026-09-27)
- Polars: [`DataFrame.corr`](https://docs.pola.rs/api/python/stable/reference/dataframe/miscellaneous.html) (read 2026-09-27)
- RapidMiner Studio: [`Correlation Matrix`](https://docs.rapidminer.com/latest/studio/operators/modeling/correlations/correlation_matrix.html) (read 2026-09-27)
- RapidMiner Studio: [`Covariance Matrix`](https://docs.rapidminer.com/latest/studio/operators/modeling/correlations/covariance_matrix.html) (read 2026-09-27)
- RapidMiner Studio: [`Mutual Information Matrix`](https://docs.rapidminer.com/latest/studio/operators/modeling/correlations/mututal_information_matrix.html) (read 2026-09-27)
- RapidMiner Studio: [`Transition Matrix`](https://docs.rapidminer.com/latest/studio/operators/modeling/correlations/transition_matrix.html) (read 2026-09-27)
