PCA.m with data containing NaN (ncnancov.m bug ?)

2 visualizaciones (últimos 30 días)
Matlab2010 el 29 de Nov. de 2013
Comentada: Stephen23 el 22 de Dic. de 2015
I can run the following,
data = randn(2.7E6,79);
[~,score,~,~,explained, ~] = pca(data);
I also have a real data matrix of the same size (79 variables, 2.7E6 observations).
Each row ( i.e. time step) has at least one NaN, in one of the variables. Because of this localSVD.m returns a blank. ie pca.m fails.
I can not replace the NaN with zero as this will change the data (the data is a differenced time series, hence zero means something very different to NaN).
I then try a different approach,
[~,score,~,~,explained, ~] = pca(data,'Algorithm','eig', 'Rows', 'pairwise');
the code fails,
Error using eig
Input to EIG must not contain NaN or Inf.
Error in pca>localEIG (line 441)
[coeff, eigValueDiag] = eig(xCov);
Error in pca (line 308)
[coeff, eigValues] = localEIG(x, vCentered, vRows, vWeights,...
Error in cce_moonShine_L1_PCA (line 28)
[~,score,~,~,explained, ~] = pca(data,'Algorithm','eig', 'Rows', 'pairwise');
I then inspect the cov matrix (79*79)
and see that one row/col is NaN. It seems like ncnancov.m is failing as it is outputting with NaN in it?
I also get this when trying,
xCov = nancov(x,'pairwise');
suggestions? How can I carry out PCA on this data?
  1 comentario
Stephen23 el 22 de Dic. de 2015
Eric's "Answer" moved here:
Hello? This just happened to me too. Does anyone from MATHWORKS want to reply?

Iniciar sesión para comentar.

Respuestas (0)


Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by