MATLAB Answers

pca: missing first pc

1 ビュー (過去 30 日間)
Raphael
Raphael 2015 年 8 月 9 日
編集済み: Raphael 2015 年 8 月 9 日
Hello community,
using the pca function i face the following problem: i have a data set X of 1000 observations (rows) and a little less variables (columns). The data consists of linear combinations of only two vectors.
if i compute pca(X) i find the coordinates of the second pc in coeff(:,1). The first one is missing.
if i compute pca(X') if find the coordinates of both in coeff(:,1) and coeff(:,2), where coeff(:,2) is equal to coeff(:,1) of pca(X).
best regards and thanks in advance Raphael

  2 件のコメント

Image Analyst
Image Analyst 2015 年 8 月 9 日
Show us. Make up a 2D matrix X and demonstrate what you say. It's hard to give you a specific fix for your problem when your problem statement is not specific.
Raphael
Raphael 2015 年 8 月 9 日
Thanks for your answer. I wrote a comment to Sagars post which is roughly the same as yours.

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

採用された回答

Sagar
Sagar 2015 年 8 月 9 日
Your question is not clear, pca(X) will give coefficient matrix whose first column represents coefficients of the first principal component and so on. You cannot do pca(X') because pca understands rows as observations and columns as variables.

  3 件のコメント

Raphael
Raphael 2015 年 8 月 9 日
thanks for your answer. I guess i found the problem. It seems like i confused observations and variables. I have round about 1000 spectra which consists of a few hundred values. I interpreted each of this values as a variable and each spectra as an observation. If I see it right now it turned out that i have to interpret them the other way round.
Still unclear is why i found the the second pc as the first column of the scores if i use my data in the wrong way.
Sagar
Sagar 2015 年 8 月 9 日
First be sure to put variables in the columns and observations in the rows. After this, if you do pca, the first column of the COEFF matrix represents the first principal component and so on. The no. of principal components will be equal to the number of variables. I don't understand what you mean by "why i found the the second pc as the first column of the scores if i use my data in the wrong way".
Raphael
Raphael 2015 年 8 月 9 日
was i ment is this: lets say x is the data matrix where columns are variables and rows are observations. That is when I interpret spectra as variables and its values (all spectra are made with the sample points) as observables.
[pc1 score1] = pca(x)
will give me the expected results. What i computed first was
[pc2 score2] = pca(x')
which was apparently wrong. The thing i'm still wondering about is why i found score2(:,1) = pc1(:,2) moreover i cant find an equivalent for pc1(:,2) in score2. maybe this is just a curios coincident and as i can now compute the right pcs its not that important. But i would like to understand this anyway :D

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

その他の回答 (0 件)

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by