From Component Scores Back to Observations
PCA converts observations into component scores: coordinates that describe each observation along the principal component directions. That transformation is useful for summarizing data, but sometimes the next task is to translate those coordinates back into approximate values for the original variables. For example, an analyst might want to inspect what a low-dimensional representation of a hypothetical set of policyholder measurements looks like in the variables’ original units.
The reconstruction depends on two pieces of information: the retained scores and the corresponding rotation vectors. It also depends on how the data were prepared before PCA. If the PCA used centering, the variable means must be added back. If it used scaling as well, the variable standard deviations must also be applied.
For one observation, write its prepared values as a row vector \(z\), its retained score row as \(t_k\), and the retained rotation vectors as the columns of \(V_k\). The row-vector convention gives \(t_k=zV_k\), and the reconstruction is \(\hat{z}=t_kV_k^\mathsf{T}\). The dimensions confirm the operation: a \(1 \times k\) score row multiplied by a \(k \times p\) transposed rotation matrix returns a \(1 \times p\) row of variable values.
Why the Reconstruction Formula Works
The rotation vectors from PCA are orthonormal: each has length one, and distinct vectors are perpendicular. If all \(p\) component directions are available, they form an orthonormal basis for the \(p\)-variable space. A prepared observation can therefore be expressed as the sum of its coordinates along those directions.
The score \(t_j\) is the projection of \(z\) onto direction \(v_j\). The full sum recovers \(z\), because the directions span the space and the scores give its coordinates in that basis. If only the first \(k\) directions are retained, the reconstruction uses only their contributions:
The discarded directions are not included, so in general \(\hat{z}\ne z\). If all directions are included and the full set of scores is available, reconstruction is exact apart from numerical rounding. Retaining fewer directions gives an approximation in the prepared-data coordinates.
Worked Reconstruction Examples
Worked Example: Reconstructing Centered Values
A hypothetical observation has three centered variable values \(x_c=(4,2,3)\). PCA uses the following three orthonormal rotation vectors, in the displayed order:
Reconstruct the observation using only the first two scores. The method is to project onto each retained vector, then combine the scores with those same vectors. The common mistake avoided here is using one score with a different component’s rotation vector.
Step 1: Calculate the retained scores. The first score is the dot product of \(x_c\) and \(v_1\):
The second score is:
Step 2: Multiply the scores by their rotation vectors and add.
Check. The first two centered values are recovered exactly. The third value is zero rather than 3 because its contribution lies entirely in the omitted direction \(v_3\). This is an approximate reconstruction, not a claim that the original observation had a third value of zero.
Worked Example: Returning a Standardized Reconstruction to Original Units
A hypothetical PCA was fitted to two variables with means \((10,100)\) and standard deviations \((2,5)\). An observation has standardized values \(z=(2,0)\). The first two rotation vectors are \(v_1=(1/\sqrt{2},1/\sqrt{2})\) and \(v_2=(1/\sqrt{2},-1/\sqrt{2})\). Retain only the first component and find the reconstructed values in the original units. The standard deviations are positive, and the given rotation vectors are orthonormal.
The method is to calculate the retained score, reconstruct the standardized values, and then reverse standardization. The common mistake avoided is stopping at standardized coordinates or adding the means without multiplying by the standard deviations.
Step 1: Calculate the first score.
Step 2: Reconstruct the standardized row from this one score.
Step 3: Reverse scaling and centering. For variable \(j\), the original value is the reconstructed standardized value times the original standard deviation, plus the original mean. Thus the first value is \(1(2)+10=12\), and the second is \(1(5)+100=105\).
Check. Standardizing the reconstructed values returns \(((12-10)/2,(105-100)/5)=(1,1)\), as required. The reconstruction is approximate because only one of the two component scores was used.
Worked Example: Reconstructing Several Rows in R
Suppose two hypothetical observations have retained, centered score rows \(2\) and \(-1\). PCA retains one rotation vector \(v_1=(0.8,0.6)\), and the variable means are \((10,20)\). Reconstruct both observations in original units. No scaling was used. This example also shows how to keep the score and rotation matrices oriented correctly in R.
Step 1: Reconstruct in centered coordinates. For the first observation, \(2(0.8,0.6)=(1.6,1.2)\). For the second, \(-1(0.8,0.6)=(-0.8,-0.6)\). In matrix form, the score matrix has two rows and one column, while the retained rotation matrix has two rows and one column.
Step 2: Add the means to each row. The first reconstructed row is \((1.6+10,1.2+20)=(11.6,21.2)\). The second is \((-0.8+10,-0.6+20)=(9.2,19.4)\).
Step 3: Match the matrix operation in R. If scores_k is the two-row score matrix and rotation_k is the two-row retained rotation matrix, the prepared-coordinate reconstruction is scores_k %*% t(rotation_k). Adding the means by column gives sweep(scores_k %*% t(rotation_k), 2, c(10, 20), "+"). The result has rows \((11.6,21.2)\) and \((9.2,19.4)\).
Check. Subtracting the means from the final rows returns \((1.6,1.2)\) and \((-0.8,-0.6)\), the centered reconstructions. The common R trap is to multiply by the rotation matrix without transposing it: the required product uses a \(k \times p\) matrix on the right and must return one column per original variable.
Using prcomp Output
For a fitted prcomp object, fit$x contains the component scores for the observations used in the fit, and fit$rotation contains the rotation vectors as columns. To reconstruct the training observations using the first \(k\) components, select the same component columns from both objects. The result of multiplying the selected scores by the transpose of the selected rotation vectors is in the coordinates that were supplied to PCA.
When prcomp used its usual centering and optional scaling, the object stores the values needed to reverse those operations. If fit$scale is a numeric vector, multiply each reconstructed column by its stored scale. If fit$center is a numeric vector, add the stored center. If either setting was disabled, that reversal is not needed for that setting.
Use the first \(k\) columns of both
fit$x and fit$rotation, in the same order.Multiply the selected score matrix by the transpose of the selected rotation matrix.
Multiply each reconstructed variable column by the corresponding stored scale.
Add the corresponding stored center to each reconstructed variable column.
The following R pattern handles the optional centering and scaling fields returned by prcomp. It assumes that \(k\) does not exceed the number of available score and rotation columns.
R code: scores_k <- fit$x[, seq_len(k), drop = FALSE]; rotation_k <- fit$rotation[, seq_len(k), drop = FALSE]; z_hat <- scores_k %*% t(rotation_k). Then use if (is.numeric(fit$scale)) z_hat <- sweep(z_hat, 2, fit$scale, "*") and if (is.numeric(fit$center)) z_hat <- sweep(z_hat, 2, fit$center, "+").
When reconstructing from scores for new observations, use the rotation vectors from the same fitted PCA and apply the same reverse preprocessing. A score row alone is not enough to recover original units: the matching rotation vectors are needed to reconstruct variable coordinates, and the original centers and scales are needed if those transformations were applied. Keep the order of variables consistent with the columns used in the fit.
Common Errors and Interpretation
- Forgetting the transpose. With scores arranged as observations by components and rotation vectors as variables by components, use \(T_kV_k^\mathsf{T}\). The resulting matrix must have one column per original variable.
- Using different component sets. The score columns and rotation columns must refer to the same components in the same order. Selecting the first \(k\) scores but unrelated rotation columns does not produce a valid reconstruction.
- Forgetting the preprocessing. A reconstruction in centered or standardized coordinates is not yet in original units. Reverse every transformation that was used, and do not reverse a transformation that was not used.
- Calling a truncated reconstruction exact. Omitted component directions contribute to the difference between the original prepared observation and its approximation. The approximation does not reveal the omitted values merely because the retained scores are known.
Reconstruction is useful for understanding what a low-dimensional representation preserves in the original variables. It is a translation back to familiar coordinates, not a guarantee that the omitted information is unimportant for a separate predictive task. This distinction is aligned with the SOA Exam PA (Predictive Analytics) syllabus.
Check Your Understanding
For each question, use the stated component vectors and preprocessing; report reconstructed values in the requested coordinates.
- A centered observation has retained scores \((3,-1)\) and rotation vectors \(v_1=(1/\sqrt{2},1/\sqrt{2})\), \(v_2=(1/\sqrt{2},-1/\sqrt{2})\). Reconstruct its two centered values. (Answer: \((\sqrt{2},2\sqrt{2})\))
- A standardized observation is reconstructed from one score \(t=2\) and rotation vector \(v=(0.6,0.8)\). The original means are \((20,50)\) and standard deviations are \((5,10)\). Find the approximate values in original units. (Answer: \((26,66)\))
- A centered three-variable observation has one retained score \(t=4\) and rotation vector \(v=(1/3,2/3,2/3)\). The original means are \((10,0,-2)\), and standard deviations are \((2,3,1)\); PCA used standardization. Find the reconstructed values in original units. (Answer: \((38/3,8,2/3)\))
- In R,
scores_khas dimensions \(6 \times 2\), androtation_khas dimensions \(4 \times 2\). What are the dimensions ofscores_k %*% t(rotation_k), and how many original variables does its output represent? (Answer: \(6 \times 4\); four original variables.) - A one-variable reconstruction in centered coordinates is \(-1.5\). The variable was centered at 12 and not scaled. What is the reconstructed original value, and what error would result from multiplying by a standard deviation of 4 even though no scaling was used? (Answer: \(10.5\); the incorrect value would be \(6\).)