# PCA with manually given PC1

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.

Thanks.

• can you explain what do you mean by "force the pc1 direction as given" ? – StupidWolf Jun 21 '20 at 9:02
• I cannot see why anyone considers this question "off-topic". It seems to be clearly formulated and on-topic. Can the moderator please justify this decision? – cdalitz Jun 22 '20 at 15:44
• @cdalitz It's unbecoming to complain in comments about moderation when the record shows that neither you nor anyone else flagged that closure for moderator review. (The only flags were requests from community members to close the question because they felt it wasn't sufficiently clear.) Whether or not that closure was correctly done, the fact is that the OP made no effort to respond and the community did not vote to reopen the thread. When you have a problem with this community, then please take it up on Meta rather than sniping from comments. – whuber Dec 17 '20 at 15:36
• @whuber Can you please point me towards information how to challenge the closure of a question? – cdalitz Dec 17 '20 at 21:02
• @cdalitz Sure: see stats.stackexchange.com/help/declined-flags and stats.stackexchange.com/help/reopen-questions. Exploring our help center, which is how I found these, may turn up more information for you. – whuber Dec 17 '20 at 21:04

## 1 Answer

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$$ 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.

• +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. – whuber Jun 21 '20 at 13:34