How to interpret an answer given by PCA

6 views (last 30 days)
Yoolla
Yoolla on 1 Apr 2016
Answered: Aditya on 8 Feb 2025
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

Answers (1)

Aditya
Aditya on 8 Feb 2025
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');

Categories

Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!