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

3 ビュー (過去 30 日間)
Matlab2010
Matlab2010 2013 年 11 月 29 日
コメント済み: Stephen23 2015 年 12 月 22 日
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
Stephen23 2015 年 12 月 22 日
Eric's "Answer" moved here:
Hello? This just happened to me too. Does anyone from MATHWORKS want to reply?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by