1
$\begingroup$

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.

$\endgroup$
5
  • 1
    $\begingroup$ can you explain what do you mean by "force the pc1 direction as given" ? $\endgroup$ – StupidWolf Jun 21 '20 at 9:02
  • $\begingroup$ 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? $\endgroup$ – cdalitz Jun 22 '20 at 15:44
  • $\begingroup$ @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. $\endgroup$ – whuber Dec 17 '20 at 15:36
  • $\begingroup$ @whuber Can you please point me towards information how to challenge the closure of a question? $\endgroup$ – cdalitz Dec 17 '20 at 21:02
  • $\begingroup$ @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. $\endgroup$ – whuber Dec 17 '20 at 21:04
4
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\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 '20 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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