Tutorials › Multivariate Statistics (Graduate) › Scaling Variables and Choosing Units

Population and Sample PCA · Tutorial 494 of 975

Scaling Variables and Choosing Units

Understand how uniform and variable-specific changes of units affect covariance matrices, PCA directions, eigenvalues, and score coefficients.

Intermediate 10 min read

What You'll Learn

  • Derive the covariance transformation for diagonal changes of measurement units
  • Prove why uniform rescaling preserves principal directions
  • Identify when rescaling variables separately changes PCA directions
  • Translate a principal-component score back to coefficients on the original variables
  • Distinguish preserved PCA axes from changes in the ordering of components

Why Measurement Units Matter in PCA

A covariance-based principal component analysis depends on the numerical scale of each variable. If a length is recorded in meters rather than centimeters, its numerical values—and its covariances with other variables—change. When every variable is rescaled in the same way, the principal directions are preserved. When variables are rescaled separately, the relative contributions to variance can change, and so can the directions PCA selects.

The key is to distinguish a change in the units used to record a variable from a change in the underlying observations. A change of units multiplies each variable by a fixed conversion factor. It does not change the ordering of observations on that variable, but it can change the numerical optimization that defines covariance PCA.

Definition: Let \(X\) be a centered random vector with \(p\) components and covariance matrix \(\Sigma=\operatorname{Cov}(X)\). A diagonal change of units has the form \(Y=DX\), where \(D=\operatorname{diag}(d_1,\ldots,d_p)\) and each \(d_j\ne 0\). Then \(d_j\) converts the numerical value of variable \(j\) into its new units. Adding a fixed offset to any component does not change its covariance matrix.

For covariance PCA, a unit-length vector \(v\) specifies the score \(v^T X\); its variance is \(v^T\Sigma v\). The first principal direction maximizes this variance over vectors with \(v^T v=1\), and subsequent directions maximize variance under orthogonality constraints. The scale changes below affect that optimization through the covariance matrix.

The Covariance Matrix After a Change of Units

For \(Y=DX\), the covariance between components \(Y_j=d_jX_j\) and \(Y_k=d_kX_k\) is \(d_jd_k\operatorname{Cov}(X_j,X_k)\). In matrix form, this gives the first central result.

Theorem: If \(X\) has finite second moments and covariance matrix \(\Sigma\), and \(Y=DX\) for a fixed matrix \(D\), then \(Y\) has covariance matrix \(D\Sigma D^T\). For a diagonal change of units, \(D^T=D\), so the result is \(D\Sigma D\).

Proof. Write \(\mu=E[X]\). By linearity of expectation, \(E[Y]=DE[X]=D\mu\), and therefore \(Y-E[Y]=D(X-\mu)\). Using the definition of covariance,

$$ \begin{aligned} \operatorname{Cov}(Y) &=E\!\left[(Y-E[Y])(Y-E[Y])^T\right]\\ &=E\!\left[D(X-\mu)(X-\mu)^TD^T\right]\\ &=D\,E\!\left[(X-\mu)(X-\mu)^T\right]D^T\\ &=D\Sigma D^T. \end{aligned} $$

The matrix \(D\) is fixed, so taking it outside the expectation requires no interchange of a limit and an integral. If a constant vector \(b\) is also added, \(Y=DX+b\), then \(Y-E[Y]=D(X-\mu)\) as well; the covariance remains \(D\Sigma D^T\). \(\square\)

For diagonal \(D\), each covariance entry is multiplied by the product of the two variables’ conversion factors:

$$ \operatorname{Cov}(Y_j,Y_k)=d_jd_k\Sigma_{jk}. $$

In particular, a variable’s variance is multiplied by \(d_j^2\). Thus a change of units can change not only the displayed variance values, but also how much each variable contributes to the total variance used by PCA.

Worked Example: Converting Both Variables From Centimeters to Meters

Suppose a centered bivariate measurement vector \(X\) has covariance matrix

$$ \Sigma= \begin{pmatrix} 4&1\\ 1&2 \end{pmatrix}, $$

where both variables are measured in centimeters. Recording both in meters gives \(Y=0.01X\), so \(D=0.01I\). The transformed covariance is

$$ \operatorname{Cov}(Y) =(0.01I)\Sigma(0.01I) =0.0001\Sigma = \begin{pmatrix} 0.0004&0.0001\\ 0.0001&0.0002 \end{pmatrix}. $$

Every entry is multiplied by \(0.0001\), because each covariance involves two measurements, each multiplied by \(0.01\). The units of the variances and covariance are now square meters. The numerical values have changed, but the common factor on the whole matrix does not change its eigenvectors, as shown below.

Uniform Rescaling Preserves Principal Directions

When every variable is multiplied by the same nonzero constant \(c\), the new covariance matrix is \(c^2\Sigma\). The principal directions remain the same, although the eigenvalues, which represent component variances, are multiplied by \(c^2\).

Theorem: Let \(\Sigma\) be a covariance matrix and \(c\ne 0\). The covariance matrix of \(cX\) is \(c^2\Sigma\). The eigenspaces of \(c^2\Sigma\) are the eigenspaces of \(\Sigma\), and every eigenvalue is multiplied by \(c^2\). Consequently, the ordered principal directions are unchanged.

Proof. By the covariance transformation result, \(\operatorname{Cov}(cX)=c^2\Sigma\). If \(\Sigma v=\lambda v\), then

$$ (c^2\Sigma)v=c^2\lambda v. $$

So every eigenvector of \(\Sigma\) is an eigenvector of \(c^2\Sigma\), with eigenvalue \(c^2\lambda\). Since \(c^2>0\), multiplication by \(c^2\) preserves the ordering of the eigenvalues. Thus the principal directions are unchanged. \(\square\)

This result covers common conversions applied to all variables, such as converting every length from centimeters to meters. It does not say that the numerical component variances are unchanged: they are rescaled along with the data.

Separate Rescaling Can Change the Directions

If the conversion factors differ by variable, the covariance becomes \(D\Sigma D\), which is generally not a constant multiple of \(\Sigma\). Its eigenvectors therefore need not match those of the original covariance matrix. There is also a useful way to describe what the new PCA means in the original coordinates.

Result: Let \(D\) be an invertible diagonal matrix, \(Y=DX\), and let \(v\) be a unit-length principal direction for \(Y\). Define \(a=Dv\). The score \(v^TY\) equals \(a^TX\), and its variance is \(a^T\Sigma a\). The constraint \(v^Tv=1\) is equivalent to \(a^TD^{-2}a=1\). Thus PCA after separate rescaling maximizes variance in the original variables under this transformed constraint, not under the usual constraint \(a^Ta=1\).

Derivation. Since \(D\) is diagonal and invertible, it is symmetric and \(v=D^{-1}a\). Hence

$$ v^TY=v^TDX=(Dv)^TX=a^TX, \qquad v^Tv=a^TD^{-2}a. $$

The score variance is consequently \(\operatorname{Var}(a^TX)=a^T\Sigma a\), while unit length of \(v\) imposes \(a^TD^{-2}a=1\). Equivalently, if \(v\) is an eigenvector of \(D\Sigma D\) with eigenvalue \(\lambda\), then multiplying \(D\Sigma Dv=\lambda v\) by \(D^{-1}\) gives

$$ \Sigma a=\lambda D^{-2}a. $$

This equation makes clear why the new direction, expressed in the original variables, is generally not an ordinary eigenvector of \(\Sigma\): it solves a different constrained optimization problem.

Worked Example: Rescaling One Variable Changes the First Direction

Let \(X\) be centered with covariance matrix

$$ \Sigma= \begin{pmatrix} 4&3\\ 3&9 \end{pmatrix}. $$

Suppose the second variable is recorded in units three times as large, so \(Y_1=X_1\) and \(Y_2=X_2/3\). Then \(D=\operatorname{diag}(1,1/3)\), and

$$ \operatorname{Cov}(Y)=D\Sigma D = \begin{pmatrix} 4&1\\ 1&1 \end{pmatrix}. $$

For the original covariance matrix, the characteristic equation is \((4-\lambda)(9-\lambda)-9=0\), or \(\lambda^2-13\lambda+27=0\). Its largest eigenvalue is \((13+\sqrt{61})/2\), approximately \(10.405\). For an eigenvector written as \((1,r)^T\), the first row of the eigenvector equation gives \(4+3r=\lambda\), so \(r=(5+\sqrt{61})/6\), approximately \(2.135\). The original first direction is therefore proportional to \((1,2.135)^T\).

For the rescaled covariance matrix, the characteristic equation is \((4-\lambda)(1-\lambda)-1=0\), or \(\lambda^2-5\lambda+3=0\). Its largest eigenvalue is \((5+\sqrt{13})/2\), approximately \(4.303\). The first row now gives \(4+r=\lambda\), so \(r=(\sqrt{13}-3)/2\), approximately \(0.303\). The new first direction in the rescaled coordinates is proportional to \((1,0.303)^T\), which differs substantially from the original direction.

To express that new score in the original variables, take \(v\) proportional to \((1,0.303)^T\). Since \(a=Dv\), the score coefficients on \(X\) are proportional to \((1,0.303/3)^T\), or approximately \((1,0.101)^T\). The component selected after rescaling therefore emphasizes the first variable much more strongly when written as a score on the original measurements.

Axes Can Stay Fixed While Their Ordering Changes

Separate scaling does not guarantee that every direction changes. For example, if the covariance matrix is diagonal, its coordinate axes are eigenvectors before and after any diagonal rescaling. But the eigenvalues can change by different factors, so which axis is the first principal direction can switch.

Worked Example: A Change of Units Reorders the Components

Suppose the centered variables are uncorrelated and have covariance matrix

$$ \Sigma= \begin{pmatrix} 9&0\\ 0&4 \end{pmatrix}. $$

The eigenvalues are \(9\) and \(4\), so the first principal direction is the first coordinate axis. Now use \(Y_1=X_1/3\) and \(Y_2=2X_2\), giving \(D=\operatorname{diag}(1/3,2)\). The new covariance matrix is

$$ D\Sigma D = \begin{pmatrix} (1/3)^2\cdot 9&0\\ 0&2^2\cdot 4 \end{pmatrix} = \begin{pmatrix} 1&0\\ 0&16 \end{pmatrix}. $$

The axes remain eigenvectors, but the largest eigenvalue is now \(16\), so the second coordinate axis is the first principal direction. Thus a statement that “rescaling preserves the axes” would not justify saying that the ordered principal components are unchanged.

Common Pitfall: Treating Every Unit Change Like a Common Factor

A frequent error is to reason that because changing units multiplies measurements by constants, it must only multiply all eigenvalues by one constant and leave PCA directions intact. That conclusion is correct only when the same factor applies to every variable. With distinct factors, each covariance entry is multiplied by \(d_jd_k\), and the matrix is generally altered in a way that changes its eigenvectors or their ordering.

A practical check is to write the conversion matrix \(D\) explicitly and calculate \(D\Sigma D\). If \(D=cI\), the directions are preserved. If the diagonal entries differ, do not assume preservation: examine the new covariance matrix and its eigenstructure. A correlation-based analysis is designed to remove positive changes of scale from individual variables, but that is a different PCA input matrix; it does not make covariance PCA itself invariant to separate changes of units.

Key takeaway: A common nonzero multiplier changes the covariance matrix by one positive scalar and preserves its ordered principal directions. Variable-specific multipliers change variances and covariances differently, so they can change the directions, the component ordering, or both.

Check Your Understanding

Use the covariance transformation and distinguish a common scale factor from separate factors.

  1. If every component of \(X\) is converted by the same nonzero factor \(c\), how do its covariance matrix, eigenvalues, and ordered principal directions change?
  2. For \(Y=\operatorname{diag}(2,1/5)X\), what multiplier applies to the covariance between \(X_1\) and \(X_2\)? What multipliers apply to their individual variances?
  3. Explain why a diagonal covariance matrix can retain the same coordinate eigenvectors after separate rescaling even though its first principal direction may change.
  4. If \(v\) is a unit principal direction in the rescaled coordinates \(Y=DX\), what is the coefficient vector for the same score expressed using \(X\)?
  5. Why does adding a fixed constant to a variable not alter a covariance-based PCA, while multiplying it by a nonzero factor can?
Clinical Biostats