Solved – Does PCA preserve observations (rows) of the data

pca

Say I have a data matrix of size $N \times P$ where $N$ is the number of samples and $P$ is the number of features. Now, if I do principal component analysis, I get another data matrix of size $N \times K$ where $K$ was chosen according to some criteria. My question: if I pick a row (sample) from the $\text{PCA}$ matrix, does it still point to the same sample as in the original data matrix?

In my study the data on each row is from one subject, so I want to know if the correspondence still exists if I use $\text{PCA}$ for feature selection. (I think this is correct but better safe than sorry…!)

Best Answer

As others said in the comments, yes, it does preserve row order. If you have a standardized data matrix $\mathbf D$ and a rotation matrix $\mathbf \Omega$, you get your rotated samples $\mathbf R$ simply doing:

$$\mathbf D \mathbf \Omega = \mathbf R$$

As you can see, by the matrix multiplication row order is preserved.

$\mathbf \Omega$ is a square matrix with $P$ rows and columns. If you want to reduce the number of PCs all you have to do is keep only the first $K$ columns of $\mathbf \Omega$.