Tutorials › Exam SRM - Statistics for Risk Modeling › PCA As Orthogonal Projection

Exam SRM · Principal Components Analysis · Tutorial 679 of 926

PCA As Orthogonal Projection

Learn why a principal component score is a dot product and how to calculate projected coordinates from centered or standardized observations.

Intermediate 12 min read

What You'll Learn

  • Derive the projection coefficient by minimizing squared distance to a component direction.
  • Calculate PCA scores using orthonormal eigenvectors.
  • Distinguish projection scores from the coordinates of an uncentered observation.
  • Apply the correct centering and scaling for covariance or correlation PCA.
  • Check two-dimensional projected coordinates using orthogonality and length.

Introduction

PCA replaces a collection of measured variables with directions through the data that summarize variation. Once those directions have been found, each observation can be described by its coordinate along each direction. That coordinate is its principal component score.

Geometrically, a score is a projection: it measures how far an observation lies along a component direction. The observation must first be expressed relative to the data center used to fit PCA. For correlation-based PCA, it must also be expressed in the standardized units used to fit the components.

Definition: Let \(x_i\) be an observation with \(p\) variables, and let \(\bar{x}\) be the vector of variable means in the data used to fit covariance-based PCA. Its centered observation is \(z_i=x_i-\bar{x}\). If \(v_j\) is a unit eigenvector giving the direction of principal component \(j\), the score of observation \(i\) on that component is \(t_{ij}=z_i^\mathsf{T}v_j\). For correlation-based PCA, use the observation centered and scaled by the same training means and standard deviations used to form the correlation matrix.

Projection onto a Component Direction

A direction is represented by a unit vector \(v\), so \(v^\mathsf{T}v=1\). The scalar projection of a centered observation \(z\) onto that direction is \(z^\mathsf{T}v\). The corresponding vector projection is \((z^\mathsf{T}v)v\). The scalar is the PCA score; the vector points from the origin to the projected location.

PCA directions obtained from a covariance matrix or correlation matrix are eigenvectors. For a symmetric matrix, its eigenvectors can be chosen orthonormal. Thus, for two distinct component directions \(v_1\) and \(v_2\), \(v_1^\mathsf{T}v_2=0\), and each direction has unit length. These conditions are what make the component scores coordinates along perpendicular axes.

Result: For a centered observation \(z\) and orthonormal component directions \(v_1,\ldots,v_p\), the score on component \(j\) is \(t_j=z^\mathsf{T}v_j\). The projection onto that direction is \(t_jv_j\). A score is a signed coordinate: its sign indicates which side of the origin the observation lies on along the chosen direction.

Why the Dot Product Gives the Projection

The score formula follows from the definition of an orthogonal projection. Among all points on the line through the origin in direction \(v\), write a candidate point as \(cv\), where \(c\) is a scalar. The squared distance from \(z\) to this candidate is

$$ \|z-cv\|^2=(z-cv)^\mathsf{T}(z-cv) =z^\mathsf{T}z-2c z^\mathsf{T}v+c^2, $$

where \(v^\mathsf{T}v=1\) has been used. This quadratic is minimized when its derivative with respect to \(c\) is zero:

$$ -2z^\mathsf{T}v+2c=0 \quad\Longrightarrow\quad c=z^\mathsf{T}v. $$

Therefore the closest point on the component line is \((z^\mathsf{T}v)v\), and its signed coordinate is \(z^\mathsf{T}v\). The perpendicularity condition can also be checked directly:

$$ \bigl(z-(z^\mathsf{T}v)v\bigr)^\mathsf{T}v =z^\mathsf{T}v-(z^\mathsf{T}v)(v^\mathsf{T}v)=0. $$

The residual from the projection is perpendicular to the direction, as required. If a direction vector is not unit length, the coefficient is instead \(z^\mathsf{T}v/(v^\mathsf{T}v)\). PCA eigenvectors are conventionally normalized to unit length, so the simpler score formula applies.

Worked Two-Dimensional Projections

In two dimensions, write a centered observation as \(z=(z_1,z_2)^\mathsf{T}\) and a component direction as \(v=(v_1,v_2)^\mathsf{T}\). The score is \(z_1v_1+z_2v_2\). Before taking that dot product, identify whether the fitted PCA used centered measurements or standardized measurements.

Worked Example: Projecting a Centered Observation

A covariance-based PCA model was fitted to two measurements. The training means are 10 and 5. Its first two component directions are \(v_1=(3/5,4/5)^\mathsf{T}\) and \(v_2=(-4/5,3/5)^\mathsf{T}\). Find the scores and projection vectors for a new observation \(x=(14,6)^\mathsf{T}\).

Method. Center the observation using the training means, then take its dot product with each unit component direction.

Step 1: Center the observation.

$$ z=x-\bar{x} =(14-10,\;6-5)^\mathsf{T} =(4,1)^\mathsf{T}. $$

Step 2: Calculate the component scores.

$$ t_1=z^\mathsf{T}v_1 =4\left(\frac35\right)+1\left(\frac45\right) =\frac{12+4}{5} =\frac{16}{5}=3.2, $$
$$ t_2=z^\mathsf{T}v_2 =4\left(-\frac45\right)+1\left(\frac35\right) =\frac{-16+3}{5} =-\frac{13}{5}=-2.6. $$

Step 3: Find each vector projection. Multiply each score by its direction:

$$ t_1v_1=\frac{16}{5}\left(\frac35,\frac45\right)^\mathsf{T} =\left(\frac{48}{25},\frac{64}{25}\right)^\mathsf{T} =(1.92,2.56)^\mathsf{T}, $$
$$ t_2v_2=-\frac{13}{5}\left(-\frac45,\frac35\right)^\mathsf{T} =\left(\frac{52}{25},-\frac{39}{25}\right)^\mathsf{T} =(2.08,-1.56)^\mathsf{T}. $$

Check. The directions are unit length and perpendicular: \(3^2+4^2=25\), and \((3/5)(-4/5)+(4/5)(3/5)=0\). The projection vectors add to \((4,1)^\mathsf{T}\), matching the centered observation. The score pair is therefore \((3.2,-2.6)\).

Common mistake avoided: using the raw observation \((14,6)\) in the dot products. The PCA axes are based at the training-data center, so the correct input is \((4,1)\), not \((14,6)\).

Worked Example: Scores from Correlation-Based PCA

A two-variable PCA uses standardized measurements. In the training data, the variable means are 50 and 20, and the sample standard deviations are 10 and 4. The fitted directions are \(v_1=(1/\sqrt{2},1/\sqrt{2})^\mathsf{T}\) and \(v_2=(1/\sqrt{2},-1/\sqrt{2})^\mathsf{T}\). Find the scores for an observation with raw values \((65,16)\). Give scores to four decimal places.

Method. Apply the training standardization to each value, then project the resulting standardized vector.

Step 1: Standardize both measurements. The standardized values are the differences from the training means divided by the corresponding training standard deviations:

$$ z_1=\frac{65-50}{10}=1.5, \qquad z_2=\frac{16-20}{4}=-1. $$

Thus the vector used for projection is \(z=(1.5,-1)^\mathsf{T}\).

Step 2: Project onto each direction.

$$ t_1=(1.5,-1) \left(\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}}\right)^\mathsf{T} =\frac{1.5-1}{\sqrt{2}} =\frac{0.5}{\sqrt{2}} \approx 0.3536, $$
$$ t_2=(1.5,-1) \left(\frac{1}{\sqrt{2}},-\frac{1}{\sqrt{2}}\right)^\mathsf{T} =\frac{1.5+1}{\sqrt{2}} =\frac{2.5}{\sqrt{2}} \approx 1.7678. $$

Check. The squared length of the standardized observation is \(1.5^2+(-1)^2=3.25\). The squared scores sum to approximately \(0.3536^2+1.7678^2=0.1250+3.1250=3.2500\), as expected for coordinates along a complete orthonormal basis.

Common mistake avoided: projecting the raw differences \((15,-4)\) without dividing by the standard deviations. That would use the units and scale of the measurements, not the standardized coordinates on which this correlation-based PCA was fitted.

Scores for Several Observations

The same projection calculation applies row by row. If the centered data matrix is \(Z\) and the matrix \(V\) has the component directions as its columns, the score matrix is \(T=ZV\). Its entry in row \(i\), column \(j\) is the dot product of centered observation \(i\) with direction \(j\). For standardized PCA, \(Z\) here denotes the matrix after applying the training means and standard deviations.

This matrix expression is a compact way to perform separate projections, not a different definition. Each row is multiplied by the direction vectors, so the output records each observation's coordinates along those directions.

Worked Example: Calculating Scores for Three Centered Points

A fitted two-dimensional PCA has directions \(v_1=(3/5,4/5)^\mathsf{T}\) and \(v_2=(-4/5,3/5)^\mathsf{T}\). Three observations, already centered using the training means, are \(z_A=(2,1)^\mathsf{T}\), \(z_B=(-1,2)^\mathsf{T}\), and \(z_C=(-1,-3)^\mathsf{T}\). Calculate each score pair and check the results.

Method. Compute each observation's dot product with each direction.

Observation A:

$$ t_{A1}=2\left(\frac35\right)+1\left(\frac45\right)=2, \qquad t_{A2}=2\left(-\frac45\right)+1\left(\frac35\right)=-1. $$

Observation B:

$$ t_{B1}=-1\left(\frac35\right)+2\left(\frac45\right)=1, \qquad t_{B2}=-1\left(-\frac45\right)+2\left(\frac35\right)=2. $$

Observation C:

$$ t_{C1}=-1\left(\frac35\right)-3\left(\frac45\right)=-3, \qquad t_{C2}=-1\left(-\frac45\right)-3\left(\frac35\right)=-1. $$

The score pairs are therefore \(A:(2,-1)\), \(B:(1,2)\), and \(C:(-3,-1)\). As a check, the centered observations sum to zero, \((2,1)+(-1,2)+(-1,-3)=(0,0)\), and the scores also sum to zero in each component: \(2+1-3=0\) and \(-1+2-1=0\).

A second check uses lengths. For A, \(2^2+(-1)^2=5=2^2+1^2\). For B, \(1^2+2^2=5=(-1)^2+2^2\). For C, \((-3)^2+(-1)^2=10=(-1)^2+(-3)^2\). Orthonormal coordinates preserve squared length when both component directions are included.

Common mistake avoided: treating the pair of scores as if each were an original measurement. They are coordinates along the fitted directions, not the original variable values.

Checks, Conditions, and Exam Traps

Projection scores are straightforward to compute, but a few conditions matter. The direction vector must be the one fitted by the PCA being applied, and the observation must be centered or standardized consistently with that fit. If the vector supplied is not unit length, the ordinary dot product is not the projection coefficient; divide by its squared length. If only some component directions are used, the resulting scores give coordinates along those directions only.

When all \(p\) orthonormal directions are included, the squared length of the centered or standardized observation equals the sum of its squared scores:

$$ z^\mathsf{T}z=\sum_{j=1}^{p}t_j^2. $$

This follows by expressing \(z\) in an orthonormal basis: its coordinate in direction \(v_j\) is \(t_j=z^\mathsf{T}v_j\). The identity is a useful arithmetic check, but it requires the complete basis. It need not hold if only a subset of component directions is included.

Exam trap: A dot product with a component direction is a score only after the observation has been put on the same scale and origin as the PCA fit. Covariance-based PCA uses centered original measurements; correlation-based PCA uses measurements standardized with the training means and standard deviations. Mixing these inputs changes the calculation.

For an observation from outside the training data, do not recalculate the training means or standard deviations using that observation. Apply the fitted preprocessing and directions. This keeps the new score on the same coordinate system as the scores of the observations used to fit the PCA.

These calculations are aligned with the SOA Exam SRM (Statistics for Risk Modeling) syllabus. A reliable solution states the preprocessing, writes the centered or standardized vector, and then shows the dot products. In two dimensions, checking that the directions are unit and perpendicular and that the projected coordinates are consistent with the input can catch arithmetic and scaling errors.

Check Your Understanding

For each problem, show the preprocessing step before calculating component scores.

  1. A covariance-based PCA has training means \((4,7)\) and first direction \(v=(3/5,4/5)^\mathsf{T}\). Find the score for \(x=(9,5)\). (Answer: \(1.4\))
  2. A correlation-based PCA uses training means \((100,30)\), standard deviations \((20,5)\), and direction \(v=(1/\sqrt{2},-1/\sqrt{2})^\mathsf{T}\). Find the score for \(x=(120,25)\), to four decimals. (Answer: \(1.4142\))
  3. Let \(z=(-2,4)^\mathsf{T}\) and \(v=(4/5,3/5)^\mathsf{T}\). Find the score and the vector projection. (Answer: score \(=0.8\); projection \(=(0.64,0.48)^\mathsf{T}\))
  4. For the orthonormal directions \(v_1=(1/\sqrt{2},1/\sqrt{2})^\mathsf{T}\) and \(v_2=(1/\sqrt{2},-1/\sqrt{2})^\mathsf{T}\), calculate both scores for \(z=(3,-1)^\mathsf{T}\), then verify the squared-length check. (Answer: scores \((\sqrt{2},2\sqrt{2})\); both squared lengths equal \(10\))
  5. A fitted PCA uses the unit direction \(v=(3/5,4/5)^\mathsf{T}\). A centered point has score \(2.5\) on this direction. Find its vector projection and state the defining perpendicularity check for the residual. (Answer: projection \(=(1.5,2.0)^\mathsf{T}\); the residual's dot product with \(v\) is \(0\))
Clinical Biostats