PCA.m with data containing NaN (ncnancov.m bug ?)
2 次查看(过去 30 天)
显示 更早的评论
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)
imagesc(isnan(xCov))
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 个评论
Stephen23
2015-12-22
Eric's "Answer" moved here:
Hello? This just happened to me too. Does anyone from MATHWORKS want to reply?
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!