help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Principal component analysis by several decomposition


From: Andreas Stahel
Subject: Re: Principal component analysis by several decomposition
Date: Mon, 10 May 2021 10:36:39 -0500 (CDT)

onewayenzyme wrote
> Hello,
>    I am coping with PCA obtained after several matrix decomposition of a
> data matrix containing biological information (for sake of completeness,
> matrix of metabolites and samples). I have a few of doubts about the
> procedure and results, then I will be greatfull to everyone who will
> address
> some (or all) of my issues.
> 
> 1. Be X a m x n data matrix (n are variables/metabolites, m
> observables/samples), n is much greater than m;
> 2. I applied a scaling by Xm=zscore(X);
> 3. performed svd by [U S W]=svd(Xm);
> 
> Assuming that W contains the principal components (PCs) of Xm (is it
> right,
> or I have to compute W'*Xm' to get them?), I can plot PCs one by one for
> each sample obtaining a biplot; now, how can I get the coefficients
> associated to each variables for each PCs?
> 
> In addition, it seems that a more ready procedure is to compute pca by
> "princomp":
> 
> [coeff,score,latent]=princomp(Xm)
> 
> and in that case the coefficients are within the "coeff" matrix, but where
> are the PCs stored? Are they in "score"?
> 
> Again, by computing PCs by eigenval decomposition:
> 
> [V,D]=eig(cov(Xm));
> 
> I will get the reconstructed V'*Xm' matrix which contains the PCs, but
> where
> are the coefficients?
> 
> 
> 
> Thank you in advance
> 
> 
> 
> 
> --
> Sent from:
> https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

Have a look at the source of  pcacov will most likely help you to answer
your questions.
Look for the file pcacov.m on your disk, it is part of the statistics
package

function [COEFF, latent, explained] = pcacov(X)
  [U,S,V] = svd(X);
  if nargout == 1
    COEFF     = U;
  elseif nargout == 2
    COEFF     = U;
    latent    = diag(S);
  else
    COEFF     = U;
    latent    = diag(S);
    explained = 100*latent./sum(latent);
  end
endfunction






--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]