本文介绍了在R中比较svd和princomp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取singular values of a matrix in R以获得主要成分,然后也将princomp(x)也用于比较结果

I want to get singular values of a matrix in R to get the principal components, then make princomp(x) too to compare results

我知道princomp()会给出主要成分

I know princomp() would give the principal components

问题

如何从$ d,$ u和$ v(s = svd(x)的解)中获取主成分?

How to get the principal components from $d, $u, and $v (solution of s = svd(x) )?

推荐答案

您可能应该研究prcomp,它使用svd而不是eigen来计算PCA(如princomp所示) .这样,如果您想要的只是PCA输出,但使用svd计算得出的结果,您将很高兴.

One way or another, you should probably look into prcomp, which calculates PCA using svd instead of eigen (as in princomp). That way, if all you want is the PCA output, but calculated using svd, you're golden.

此外,如果您在命令行中键入stats:::prcomp.default,则可以自己查看它如何使用svd的输出.

Also, if you type stats:::prcomp.default at the command line, you can see how it's using the output of svd yourself.

这篇关于在R中比较svd和princomp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 07:36