HAHS.
Back to Catalog

Correlation Matrix

chart

Also known as: correlation heatmap, correlation plot, correlogram

Show relationshipCompareShow distribution Numerical Matrix/Grid

설명 / Description

상관 행렬은 여러 수치형 변수 사이의 쌍별 상관 계수를 대칭 격자로 표시합니다. 각 셀은 두 변수 사이의 관계를 나타내며, 색상이 상관 값을 인코딩합니다 — 보통 강한 음의 상관(예: 파랑)에서 0(흰색 또는 밝은 색)을 지나 강한 양의 상관(예: 빨강)으로 이어지는 발산형 색상 스케일을 사용합니다. 대각선은 항상 완벽한 자기 상관(+1)을 보여주며, 행렬은 대각선을 중심으로 대칭입니다.

A correlation matrix displays the pairwise correlation coefficients between a set of numerical variables in a symmetric grid. Each cell represents the relationship between two variables, with color encoding the correlation value: typically a diverging scale from strong negative (e.g., blue) through zero (white or light) to strong positive (e.g., red). The diagonal always shows perfect self-correlation (+1), and the matrix is symmetric around it.

이 시각화는 탐색적 데이터 분석에서 강력한 스크리닝 도구 역할을 합니다. 색상 패턴을 훑어보면 분석가는 어떤 변수 쌍이 함께 움직이는지(양의 상관), 어떤 쌍이 반대 방향으로 움직이는지(음의 상관), 어떤 쌍이 거의 관련이 없는지(0에 가까운 상관)를 빠르게 파악할 수 있습니다. 비슷한 색상의 셀들이 뭉쳐 있으면 함께 변동하는 변수 그룹을 드러내며, 이는 잠재 요인이나 회귀 모델의 다중공선성 문제를 시사할 수 있습니다.

The visualization serves as a powerful screening tool in exploratory data analysis. By scanning the color pattern, an analyst can quickly identify which pairs of variables move together (positive correlation), which move in opposite directions (negative correlation), and which are largely unrelated (near-zero correlation). Clusters of similarly colored cells reveal groups of co-varying variables, suggesting underlying factors or potential multicollinearity issues in regression models.

상관 행렬은 정보 밀도가 높지만, 위치보다 정확도가 떨어지는 색상 지각에 의존합니다. 독자는 강한 상관과 약한 상관은 쉽게 구별하지만, 미세한 차이(예: 0.72 대 0.68)는 구별하기 어렵습니다. 셀에 숫자 값을 주석으로 표시하거나 클릭 시 인터랙티브 산점도와 짝을 이루게 하면 이 한계를 보완할 수 있습니다.

While the correlation matrix is information-dense, it relies on color perception, which is less precise than position. Readers can easily distinguish strong from weak correlations but struggle with fine differences (e.g., 0.72 vs. 0.68). Annotating cells with numeric values or pairing the matrix with an interactive scatterplot on click can address this limitation.

Correlation Matrix — interactive example

언제 사용하나 / When to Use

  • 하나의 컴팩트한 뷰에서 많은 변수(5~50개 이상) 사이의 쌍별 관계를 탐색할 때
  • Exploring pairwise relationships among many variables (5-50+) in a single compact view
  • 회귀 모델을 만들기 전에 다중공선성을 스크리닝할 때
  • Screening for multicollinearity before building regression models
  • 잠재 요인을 시사하는, 함께 변동하는 변수 클러스터를 식별할 때
  • Identifying variable clusters that co-vary, suggesting latent factors
  • 데이터셋의 전체 관계 구조를 한눈에 전달할 때
  • Communicating the overall relationship structure of a dataset at a glance

이럴 땐 피하세요 / When NOT to Use

  • 변수가 2~3개뿐일 때 -- 산점도산점도 행렬이 더 많은 세부 정보를 보여줍니다
  • When you have only 2-3 variables -- a scatterplot or scatterplot matrix shows more detail
  • 관계가 비선형일 때 -- 상관 계수는 선형 연관성만 측정하므로, 실제 형태를 보려면 산점도를 사용하세요
  • When the relationship is non-linear -- correlation coefficients measure linear association only; use a scatterplot to see the actual shape
  • 정확한 값이 중요할 때 -- 색상 구별은 정밀하지 않으므로 숫자 주석을 추가하거나 표를 사용하세요
  • When precise values are critical -- color discrimination is imprecise; add numeric annotations or use a table
  • 범주형 데이터의 경우 -- 상관은 수치형 변수에 대해서만 정의되므로, 대신 분할표나 모자이크 플롯을 사용하세요
  • For categorical data -- correlation is defined for numerical variables; use a contingency table or mosaic plot instead

구조 / Anatomy

  • 격자 셀: 각 (i, j) 위치에 있는 정사각형 셀로, 변수 i와 j 사이의 상관 계수에 따라 색이 칠해집니다.
  • Grid cells: Square cells at each (i, j) position, colored by the correlation coefficient between variables i and j.
  • 색상 스케일: 0을 중심으로 한 발산형 스케일(예: 파랑-흰색-빨강)로, 값과 색상의 매핑을 보여주는 범례가 있습니다.
  • Color scale: A diverging scale (e.g., blue-white-red) centered at zero, with a legend showing the value-to-color mapping.
  • 대각선: 자기 상관(항상 1.0)으로, 보통 중립색으로 표시되거나 생략됩니다.
  • Diagonal: Self-correlations (always 1.0), often shown in a neutral color or omitted.
  • 변수 레이블: 양쪽 축을 따라 같은 순서로 표시되는 이름.
  • Variable labels: Names along both axes, in the same order.
  • 셀 주석: 정밀도를 위해 각 셀 안에 표시되는 선택적 숫자 값(예: "0.85").
  • Cell annotations: Optional numeric values (e.g., "0.85") printed inside each cell for precision.
  • 상단/하단 삼각형: 행렬이 대칭이므로, 한쪽 삼각형은 때때로 숨겨지거나 다른 인코딩(예: 원 크기)으로 대체됩니다.
  • Upper/lower triangle: Since the matrix is symmetric, one triangle is sometimes hidden or replaced with a different encoding (e.g., circle size).

변형 / Variations

  • 반쪽 행렬: 하단(또는 상단) 삼각형만 표시하여 중복을 제거합니다.
  • Half-matrix: Only the lower (or upper) triangle is shown, eliminating redundancy.
  • 클러스터링된 상관 행렬: 계층적 군집화로 변수 순서를 재배열하여 상관된 변수들을 함께 묶습니다.
  • Clustered correlation matrix: Variables are reordered by hierarchical clustering to group correlated variables together.
  • 버블 상관 행렬: 원 크기가 상관 값의 절대값을 인코딩하고 색상이 방향을 인코딩하여 이중 인코딩을 제공합니다.
  • Bubble correlation matrix: Circle size encodes the absolute correlation value, and color encodes direction, providing a dual encoding.
  • 주석이 달린 행렬: 색상 채우기와 함께 각 셀에 숫자 상관 값을 표시합니다.
  • Annotated matrix: Numeric correlation values printed in each cell alongside the color fill.
  • 유의성 마스킹 행렬: 유의하지 않은 상관에 해당하는 셀은 비워두거나 "X"로 표시됩니다.
  • Significance-masked matrix: Cells for non-significant correlations are blanked out or marked with an "X".

코드 레퍼런스 / Code Reference

// Observable Plot - correlation matrix
Plot.plot({
  marks: [
    Plot.cell(correlations, {
      x: "var1",
      y: "var2",
      fill: "r",
      tip: true
    }),
    Plot.text(correlations, {
      x: "var1",
      y: "var2",
      text: d => d.r.toFixed(2),
      fill: d => Math.abs(d.r) > 0.5 ? "white" : "black",
      fontSize: 10
    })
  ],
  color: {
    scheme: "RdBu",
    pivot: 0,
    domain: [-1, 1],
    legend: true,
    label: "Correlation"
  },
  x: { label: null, tickRotate: -45 },
  y: { label: null }
})