Borrar filtros
Borrar filtros

How to calculate scores when using pcacov?

5 visualizaciones (últimos 30 días)
JUAN DAVID PEREZ
JUAN DAVID PEREZ el 21 de Mayo de 2016
Respondida: arushi el 21 de Ag. de 2024 a las 10:13
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.

Respuestas (1)

arushi
arushi el 21 de Ag. de 2024 a las 10:13
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.

Categorías

Más información sobre Dimensionality Reduction and Feature Extraction en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by