2

I'm working with large data sets (matrices of dimension 6000 x 3072), and using the prcomp() function to do my principal component calculation. However, the function is extremely slow. Even using the rank argument which can limit the number of components to calculate, it still takes 7-8 minutes. Now, I need to calculate principal components 45 times, as well as do some other intermediate calculation that take a few minutes on their own. So I don't want to sit staring at my computer screen for 8-9 hours on this simple analysis.

What are the fastest principal component analysis packages, I can use to speed up the process. I only need to calculate the first 20, so, so the majority of the computation can be ignored.

d.b
  • 32,245
  • 6
  • 36
  • 77
Zuhaib Ahmed
  • 487
  • 4
  • 14
  • 1
    Questions asking for package recommendations are off-topic for the site. However, you can try to use a `data.table` way so as to leverage `data.table`'s speed. I don't know how fast this is but it might help: `FactoMineR::PCA()` – NelsonGon Feb 20 '19 at 17:46
  • @NelsonGon - Thank you for the reply. Is there a place that I can ask where this might be more relevant? – Zuhaib Ahmed Feb 20 '19 at 17:55
  • 2
    I'm not sure. Maybe over at cross-validated(not sure). Try the suggestions [here](https://stackoverflow.com/questions/8299460/what-is-the-fastest-way-to-calculate-first-two-principal-components-in-r) and there are a couple of packages used in the answers. – NelsonGon Feb 20 '19 at 17:57
  • You can run 45 parallel jobs and finish your tasks in 8 minutes (if you have access to multiple cores) – pogibas Feb 20 '19 at 17:59
  • https://github.com/yixuan/rARPACK/blob/master/man/eigs.Rd ? – Ben Bolker Feb 20 '19 at 18:06
  • Use the Math Kernel Library (MKL). You can either install Microsoft R Open or follow this question https://stackoverflow.com/questions/38090206/linking-intels-math-kernel-library-mkl-to-r-on-windows. Hope it helps you. – Santiago Capobianco Feb 20 '19 at 18:29
  • https://privefl.github.io/blog/fast-r-functions-to-get-first-principal-components/ – F. Privé Feb 20 '19 at 20:58
  • You might also rewrite / rephrase your question so it better fits the format here on SO. Possibly asking about "methodology" rather than recommendations for software could be a better fit. – StayOnTarget Feb 20 '19 at 21:39

0 Answers0