gpt4 book ai didi

Discrepancies in PCA results using prcomp in different R environments(不同R环境下使用prcomp的PCA结果存在差异)

转载 作者:bug小助手 更新时间:2023-10-22 18:05:09 27 4
gpt4 key购买 nike



I am working on a project with a friend where we are both using the prcomp function in R to perform Principal Component Analysis (PCA) on the same dataset with the prcomp function. However, we have encountered an issue where the PCA results are not consistent between our two environments; specifically, the signs of some of the principal components are flipped (some values that are positive in one environment are negative in the other, and vice versa).

我和一个朋友正在做一个项目,我们都在使用R中的prcomp函数对具有prcomp功能的同一数据集执行主成分分析(PCA)。然而,我们遇到了一个问题,即PCA结果在我们的两个环境之间不一致;具体地说,一些主要成分的符号被翻转(一些在一个环境中为正的值在另一个环境下为负,反之亦然)。


The R vestions are ‘4.3.1’ and '4.2.2' but I don't think this causes the issue.

R值为“4.3.1”和“4.2.2”,但我不认为这会导致问题。


Could anyone let me know why it may happen?

有人能告诉我为什么会发生这种事吗?


更多回答

Not sure why it's occurring (sorry), but I remember running into this problem years ago and being told the sign doesn't matter with PCA, only the variance matters. Explained here: stats.stackexchange.com/a/88882

不知道为什么会发生这种情况(对不起),但我记得几年前遇到过这个问题,被告知符号与PCA无关,只有方差才重要。此处解释:stats.stackexchange.com/a/88882

优秀答案推荐

As @jared_mamrot said https://stats.stackexchange.com/a/88882 is a very relevant answer. It is not exactly that the signs in general don't matter though, but if all the signs are flipped, it doesn't matter.

正如@jared_mamrot所说https://stats.stackexchange.com/a/88882是一个非常相关的答案。不过,并不是说这些标志总体上无关紧要,但如果所有的标志都被翻转了,那也没关系。


The fact that prcomp choses one or the other of the equivalent transformations in principal components might be linked to the order of the columns or some other random difference in the way you treat the data.

prcomp在主组件中选择一个或另一个等效转换的事实可能与列的顺序或处理数据的其他随机差异有关。


更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com