How to interpret an answer given by PCA

8 ビュー (過去 30 日間)
Yoolla
Yoolla 2016 年 4 月 1 日
回答済み: Aditya 2025 年 2 月 8 日 17:46
Hello,
I have matrix consisted of 30 variables(columns) and 14 observation(rows). Many of these variables are basically measuring similar activities. Thus I decided to use PCA to decrease the dimensionality.
There are two major problem:
1- These variables have different unites some are time values and some are number of repetitions. can I use the row data for PCA, or do I need to normalize them beforehand? In the latter case, what would be the best way of normalization?
2- If I decided to take the first two pca components how could I find out which variables are explained by which component? You can find it out by SPSS, but I would not know how to do it by MATLAB.
your helps would be highly appreciated,
cheers
Yoolla

回答 (1 件)

Aditya
Aditya 2025 年 2 月 8 日 17:46
Hi Yoolla,
When performing PCA, especially with variables measured in different units, it's crucial to ensure that the data is properly prepared. Here's how you can address the issues you've mentioned:
  1. Normalization
  2. Interpreting PCA Components
% Assume your data matrix is named 'dataMatrix' with size 14x30
normalizedData = zscore(dataMatrix);
% Min-Max Scaling
minVals = min(dataMatrix);
maxVals = max(dataMatrix);
scaledData = (dataMatrix - minVals) ./ (maxVals - minVals);
% Perform PCA on the normalized data
[coeff, score, latent, tsquared, explained] = pca(normalizedData);
% Display the coefficients for the first two principal components
disp('Coefficients for the first two principal components:');
disp(coeff(:, 1:2));
% You can also visualize the loadings
figure;
biplot(coeff(:, 1:2), 'Scores', score(:, 1:2), 'VarLabels', arrayfun(@(x) sprintf('Var%d', x), 1:size(dataMatrix, 2), 'UniformOutput', false));
title('Biplot of First Two Principal Components');
xlabel('Principal Component 1');
ylabel('Principal Component 2');

カテゴリ

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