{
  "id": "correlation-matrix",
  "title": "Correlation Matrix",
  "lang": "en",
  "source_lang": "en",
  "summary": "A correlation matrix records pairwise correlations among variables, summarizing their standardized associations and providing a basis for multivariate statistical analysis.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "Matrix of correlations"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/correlation-matrix/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/correlation-matrix/",
      "json": "https://aiwiki.page/zh/correlation-matrix.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "A correlation matrix is a square matrix whose entries are the correlation coefficients between pairs of variables. In its usual form, it contains Pearson correlations, which measure linear association after accounting for differences in scale. Correlation matrices are fundamental tools in statistics: they summarize relationships among many variables and support methods such as regression, dimension reduction, and multivariate modeling."
    },
    {
      "heading": "Definition",
      "text": "Let \\(X_1,\\ldots,X_p\\) be real-valued random variables with finite, strictly positive variances. Their population correlation matrix is the \\(p\\times p\\) matrix \\(R\\) with entries\n\n\\[R_{ij}=\\rho_{ij} =\\frac{\\operatorname{Cov}(X_i,X_j)} {\\sigma_i\\sigma_j},\\]\n\nwhere \\(\\operatorname{Cov}(X_i,X_j)\\) is their covariance and \\(\\sigma_i=\\sqrt{\\operatorname{Var}(X_i)}\\) is the standard deviation of \\(X_i\\).\n\nIf \\(\\Sigma\\) is the covariance matrix of the variables and\n\n\\[D=\\operatorname{diag}(\\sigma_1,\\ldots,\\sigma_p),\\]\n\nthen\n\n\\[R=D^{-1}\\Sigma D^{-1}.\\]\n\nEquivalently, define standardized variables\n\n\\[Z_i=\\frac{X_i-\\mathbb{E}[X_i]}{\\sigma_i},\\]\n\nwhere \\(\\mathbb{E}[X_i]\\) denotes the expected value. The correlation matrix of the original variables is the covariance matrix of these standardized variables:\n\n\\[R=\\mathbb{E}[ZZ^{\\mathsf T}], \\qquad Z=(Z_1,\\ldots,Z_p)^{\\mathsf T}.\\]\n\nA variable with zero variance has no defined Pearson correlation, including with itself, because the formula divides by its standard deviation. Variables without finite second moments also fall outside this definition."
    },
    {
      "heading": "Mathematical properties",
      "text": "Every population Pearson correlation matrix has the following properties:\n\n- Symmetry: \\(R_{ij}=R_{ji}\\).\n- Unit diagonal: \\(R_{ii}=1\\).\n- Bounded entries: \\(-1\\leq R_{ij}\\leq 1\\).\n- Positive semidefiniteness: \\(a^{\\mathsf T}Ra\\geq 0\\) for every real vector \\(a\\).\n\nThe bound on individual entries follows from the Cauchy–Schwarz inequality. Positive semidefiniteness follows because\n\n\\[a^{\\mathsf T}Ra = \\operatorname{Var}\\!\\left(\\sum_{i=1}^{p}a_iZ_i\\right) \\geq 0.\\]\n\nThus all eigenvalues of a correlation matrix are nonnegative. Their sum is \\(p\\), since the diagonal entries are all one.\n\nA correlation matrix is a positive definite matrix precisely when no nonzero linear combination of the standardized variables has zero variance. Otherwise it is singular: some exact linear relationship exists among the centered variables.\n\nCompatibility of pairwise correlations\n\nSymmetry, unit diagonal, and entries between \\(-1\\) and \\(1\\) are not sufficient to make an arbitrary array a valid correlation matrix. The correlations must also be mutually compatible.\n\nFor three variables, write\n\n\\[R= \\begin{pmatrix} 1&a&b\\\\ a&1&c\\\\ b&c&1 \\end{pmatrix}.\\]\n\nIn addition to \\(|a|,|b|,|c|\\leq 1\\), validity requires\n\n\\[\\det(R)=1+2abc-a^2-b^2-c^2\\geq 0,\\]\n\nwhere \\(\\det(R)\\) is the determinant. For example, two correlations of \\(0.9\\) and a third correlation of \\(-0.9\\) cannot coexist in such a matrix.\n\nConversely, every real symmetric positive semidefinite matrix with unit diagonal is the correlation matrix of some random vector. One construction uses a possibly degenerate multivariate normal distribution with that matrix as its covariance matrix. This existence result does not mean that arbitrary prescribed marginal distributions can realize every such matrix."
    },
    {
      "heading": "Sample correlation matrix",
      "text": "For \\(n\\) observations of \\(p\\) variables, let \\(x_{ki}\\) be observation \\(k\\) of variable \\(i\\). The usual sample Pearson correlation is\n\n\\[r_{ij} = \\frac{ \\sum_{k=1}^{n}(x_{ki}-\\bar{x}_i)(x_{kj}-\\bar{x}_j) }{ \\sqrt{ \\sum_{k=1}^{n}(x_{ki}-\\bar{x}_i)^2 \\sum_{k=1}^{n}(x_{kj}-\\bar{x}_j)^2 } },\\]\n\nwhere \\(\\bar{x}_i\\) is the sample mean.\n\nLet \\(Z\\) be the \\(n\\times p\\) data matrix after centering each column and dividing it by its sample standard deviation, calculated with denominator \\(n-1\\). Then\n\n\\[\\widehat{R}=\\frac{1}{n-1}Z^{\\mathsf T}Z.\\]\n\nThe common covariance normalization cancels in each correlation coefficient, so using denominator \\(n\\) consistently in the covariance and variance calculations produces the same correlation matrix.\n\nThe representation as \\(Z^{\\mathsf T}Z\\) shows that the sample correlation matrix is a scaled Gram matrix and is positive semidefinite. Its rank satisfies\n\n\\[\\operatorname{rank}(\\widehat{R})\\leq \\min(p,n-1).\\]\n\nConsequently, if \\(p\\geq n\\), the ordinary sample correlation matrix is necessarily singular, assuming every included column has positive sample variance.\n\nMissing observations\n\nWhen observations are missing, the way correlations are computed affects the matrix:\n\n- Complete-case calculation uses the same observations for every variable pair. If all retained variables have positive variance, the resulting ordinary sample correlation matrix is positive semidefinite.\n- Pairwise-complete calculation uses all available observations separately for each pair. It may retain more data for individual entries, but the assembled matrix need not be positive semidefinite because its entries can come from different subsets.\n- Model-based estimation or imputation can produce a coherent joint estimate, but its validity depends on the method and assumptions about missingness. Missing-data imputation also affects how estimation uncertainty should be assessed."
    },
    {
      "heading": "Interpretation and geometry",
      "text": "A positive entry indicates that larger values of one variable tend to accompany larger values of the other in a linear sense. A negative entry indicates an opposing linear tendency. An entry close to zero indicates weak linear association, not necessarily an absence of other relationships.\n\nThe coefficients are dimensionless. Adding a constant to a variable or multiplying it by a positive constant leaves its correlations unchanged. Multiplying it by a negative constant reverses the signs of its off-diagonal correlations.\n\nFor example,\n\n\\[R= \\begin{pmatrix} 1&0.8&-0.2\\\\ 0.8&1&-0.1\\\\ -0.2&-0.1&1 \\end{pmatrix}\\]\n\ndescribes a strong positive linear association between the first two variables and weaker negative associations involving the third.\n\nThere is also a geometric interpretation. Center each observed variable and scale its observation vector to have unit Euclidean length. The correlation between two variables is then the inner product of their vectors, or their cosine similarity. Thus:\n\n- correlation \\(1\\) corresponds to identical directions;\n- correlation \\(-1\\) corresponds to opposite directions;\n- correlation \\(0\\) corresponds to orthogonal directions.\n\nFor these unit vectors \\(u_i,u_j\\),\n\n\\[\\|u_i-u_j\\|^2=2(1-r_{ij}).\\]\n\nThis identity connects correlations to distances used in some forms of cluster analysis."
    },
    {
      "heading": "Alternative correlation matrices",
      "text": "“Correlation matrix” can also refer to a matrix constructed using association measures other than Pearson correlation. The measure should therefore be specified when ambiguity matters.\n\nRank-based matrices\n\nA Spearman correlation matrix contains Pearson correlations between ranked variables. It summarizes monotonic rather than strictly linear relationships and reduces sensitivity to the numerical magnitude of extreme observations. When all columns are ranked using a common complete dataset, its positive semidefiniteness follows from the ordinary sample correlation construction.\n\nA Kendall correlation matrix contains coefficients based on concordant and discordant observation pairs. Kendall coefficients have a different interpretation from Pearson coefficients, and different treatments of ties lead to different variants.\n\nRank correlations are not interchangeable with Pearson correlations. They need not represent the linear correlations of the original numerical measurements.\n\nPartial correlation matrices\n\nA partial correlation measures linear association after removing the linear effects of specified other variables. If \\(R\\) is positive definite and\n\n\\[\\Omega=R^{-1},\\]\n\nthen the partial correlation between variables \\(i\\) and \\(j\\), controlling for all remaining variables, is\n\n\\[\\rho_{ij\\cdot\\text{others}} = -\\frac{\\Omega_{ij}} {\\sqrt{\\Omega_{ii}\\Omega_{jj}}}.\\]\n\nHere \\(R^{-1}\\) is the inverse matrix. A table of partial correlations with diagonal entries set to one is not generally positive semidefinite, despite often being called a partial correlation matrix.\n\nFor a nonsingular multivariate normal distribution, a zero off-diagonal entry of \\(\\Omega\\) corresponds to conditional independence between the associated variables given all the others. Outside that setting, a zero partial correlation generally establishes only the absence of the corresponding residual linear association."
    },
    {
      "heading": "Applications",
      "text": "Multivariate exploration\n\nCorrelation matrices provide a compact view of pairwise associations. Heatmaps often display coefficients using color, with variables reordered to reveal groups of related measurements. Such ordering changes the presentation, not the underlying coefficients.\n\nPrincipal component analysis\n\nPrincipal component analysis can be performed on either a covariance matrix or a correlation matrix. Using a correlation matrix is equivalent to performing covariance-based PCA after standardizing every variable to unit variance.\n\nThis gives variables equal variance before decomposition, which can be useful when their units differ substantially. It also removes original variance differences, including differences that may be scientifically meaningful.\n\nRegression\n\nIn linear regression, the correlation matrix of predictors describes their pairwise linear relationships. Small eigenvalues can reveal near-linear dependencies involving several predictors, even when no single pair has an exceptionally high correlation.\n\nFor ordinary least squares with an intercept and standardized, full-rank predictors and response, the standardized coefficient vector satisfies\n\n\\[\\widehat{\\beta}=\\widehat{R}_{XX}^{-1}\\widehat{r}_{Xy},\\]\n\nwhere \\(\\widehat{R}_{XX}\\) is the predictor correlation matrix and \\(\\widehat{r}_{Xy}\\) contains predictor–response correlations.\n\nSimulation and covariance construction\n\nIf marginal standard deviations are known, a correlation matrix determines the corresponding covariance matrix through\n\n\\[\\Sigma=DRD.\\]\n\nFor a positive definite \\(R\\), a Cholesky decomposition \\(R=LL^{\\mathsf T}\\) can be used to generate correlated normal variables: if \\(U\\) has independent standard normal components, then \\(LU\\) has covariance and correlation matrix \\(R\\). Singular matrices require a factorization that permits zero eigenvalues."
    },
    {
      "heading": "Estimation and numerical issues",
      "text": "Sample correlations are estimates, not exact population quantities. Their precision depends on the sample size, the underlying distribution, dependence among observations, and the sampling design. Pearson correlations can be strongly influenced by outliers.\n\nWhen many variables are measured relative to the number of observations, the sample matrix may be singular or poorly conditioned. Its inverse can then be undefined or highly sensitive to small changes in the data. Regularization methods can stabilize estimation. A simple example is shrinkage toward the identity matrix:\n\n\\[\\widehat{R}_{\\lambda} = (1-\\lambda)\\widehat{R}+\\lambda I, \\qquad 0\\leq\\lambda\\leq1.\\]\n\nIf \\(\\widehat{R}\\) is positive semidefinite, this preserves the unit diagonal and is positive definite for \\(\\lambda>0\\). It reduces estimated off-diagonal correlations toward zero while introducing bias.\n\nRounding, pairwise deletion, or separately estimated coefficients can produce a matrix with negative eigenvalues. Methods for finding a nearby valid correlation matrix impose positive semidefiniteness and a unit diagonal. The resulting entries depend on the chosen distance criterion and constraints; repairing mathematical validity does not establish that the adjusted values are statistically well estimated."
    },
    {
      "heading": "Limitations",
      "text": "A correlation matrix captures only selected pairwise relationships. It generally does not determine the full joint probability distribution.\n\nIn particular:\n\n- Zero Pearson correlation does not imply statistical independence. For jointly normal variables, however, a diagonal correlation matrix does imply mutual independence.\n- Strong nonlinear dependence can coexist with zero Pearson correlation.\n- Pairwise coefficients may conceal subgroup patterns, temporal structure, or higher-order relationships.\n- Correlations may change after conditioning, aggregation, or selection of observations.\n- A matrix of associations does not by itself establish causation; causal interpretation requires additional assumptions or evidence.\n- Examining many entries introduces multiple testing issues when individual correlations are subjected to significance tests."
    }
  ],
  "links": [
    "matrix",
    "correlation",
    "statistics",
    "random-variable",
    "covariance",
    "standard-deviation",
    "covariance-matrix",
    "expected-value",
    "cauchy-schwarz-inequality",
    "eigenvalues-and-eigenvectors",
    "positive-definite-matrix",
    "determinant",
    "multivariate-normal-distribution",
    "sample-mean",
    "gram-matrix",
    "matrix-rank",
    "missing-data-imputation",
    "inner-product",
    "cosine-similarity",
    "cluster-analysis",
    "inverse-matrix",
    "conditional-independence",
    "principal-component-analysis",
    "linear-regression",
    "cholesky-decomposition",
    "sample-size",
    "regularization",
    "identity-matrix",
    "joint-probability-distribution",
    "statistical-independence",
    "causation",
    "multiple-testing"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}