I’m trying to apply PCA on my data using princomp(x), that has been standardized.
The data is <16 x 1036800 double>. This runs our of memory which is too be expected except for the fact that this is a new computer, the computer holds 24GB of RAM for data mining. MATLAB even lists the 24GB available on a memory check.
Is MATLAB actually running out of memory while performing a PCA or is MATLAB not using the RAM to it’s full potential? Any information or ideas would be helpful. (I may need to increase the virtual memory but assumed the 24GB would have sufficed.)
For a data matrix of size n-by-p,
PRINCOMPwill return a coefficient matrix of size p-by-p where each column is a principal component expressed using the original dimensions, so in your case you will create an output matrix of size:Consider using
PRINCOMP(X,'econ')to return only the PCs with significant varianceAlternatively, consider performing PCA by SVD: in your case
n<<p, and the covariance matrix is impossible to compute. Therefore, instead of decomposing the p-by-p matrixXX', it is sufficient to only decompose the smaller n-by-n matrixX'X. Refer to this paper for reference.EDIT:
Here’s my implementation, the outputs of this function match those of PRINCOMP (the first three anyway):
I just tried it on my 4GB machine, and it ran just fine:
Update:
The
princompfunction became deprecated in favor ofpcaintroduced in R2012b, which includes many more options.