I am using R function prcomp to do PCA on my data set. I wonder if i want to force the pc1 direction as given and perform the PCA analysis on the rest, how can i do it.



1 Answer 1


Let me reformulate your question: you want to do a PCA on the subspace that is orthogonal to a given direction PC1 $\vec{p}_1$.

You can project every data point $\vec{x}$ on that subspace by $$\vec{x}_{proj} = \vec{x} - \langle \vec{x},\vec{p}_1\rangle\cdot \vec{p}_1$$ where $\langle.,.\rangle$ denotes the scalar product. Then simply do a PCA on the projected data. Note that the R function prcomp will return $\vec{p}_1$ as the last direction, so you should ignore the last returned column.

  • 3
    $\begingroup$ +1. This is a nice generalization of the usual option of centering the data before performing PCA, which is the case $p_1 = (1,1,\ldots, 1).$ Your solution can be further generalized to multiple given "principal components" simply by regressing the data (as a multivariate response) against the set of given components and performing PCA on the residuals. $\endgroup$
    – whuber
    Jun 21, 2020 at 13:34
  • 1
    $\begingroup$ this is missing a $\vec{p_1}$ which multiplies the inner product. $\endgroup$ Jan 24, 2023 at 15:59
  • 1
    $\begingroup$ @john-madden Thanks for spotting this. It is corrected. $\endgroup$
    – cdalitz
    Jan 24, 2023 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.