How to calculate scores when using pcacov?

6 views (last 30 days)
JUAN DAVID PEREZ
JUAN DAVID PEREZ on 21 May 2016
Answered: arushi on 21 Aug 2024
I want to perform PCA analysis. When using pcacov function, it is not returned the scores. Could any of you guys help me with this problem? I know that using pca function scores are returned. But I am not using pca function because I want to perform PCA analysis using the Spearman correlation matrix obtained instead of Pearson. Thanks a lot for your help.

Answers (1)

arushi
arushi on 21 Aug 2024
Hi Juan,
To perform PCA using a Spearman correlation matrix and obtain scores, you'll need to follow a few steps, as the pcacov function in MATLAB does not directly return scores. Here's how you can accomplish this:Steps to Perform PCA with Spearman Correlation
Compute the Spearman Correlation Matrix:
  • First, calculate the Spearman correlation matrix for your data. You can use the corr function with the 'Spearman' option:
data = [...]; % Your data matrix
spearmanCorr = corr(data, 'Type', 'Spearman')
Perform PCA Using pcacov:
  • Use the pcacov function to perform PCA on the Spearman correlation matrix. This function will return the eigenvectors (coefficients) and eigenvalues, among other outputs.
Compute the Scores Manually:
  • To obtain the scores, you need to project your standardized data onto the principal component space. First, standardize your data (mean = 0, variance = 1), and then multiply by the coefficients:
[coeff, latent, explained] = pcacov(spearmanCorr);
standardizedData = zscore(data);
scores = standardizedData * coeff;
Hope this helps.

Categories

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

Community Treasure Hunt

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

Start Hunting!