Solved – factor analysis for given data with help of matlab

factor analysisMATLABpca

suppose that we have following data

enter image description here

i have done covariance matrix and eigenvalue decomposition

>> means=mean(X);
>> centered=X-repmat(means,10,1);
>> covariance=(centered'*centered)/(9);

>> [V,D]=eig(covariance);
>> [e,i]=sort(diag(D),'descend');
>> sorted=V(:,i);

e

e =

   1.0e+03 *

    3.8861
    0.4605
    0.1162
    0.0465

>> sorted

sorted =

    0.5080    0.5042    0.3747   -0.5893
    0.0090   -0.6091    0.7930   -0.0092
    0.8560   -0.3490   -0.2747    0.2647
    0.0955    0.5030    0.3941    0.7633

i have calculated also percentage distribution

(e./sum(e))*100

ans =

   86.1796
   10.2125
    2.5776
    1.0303

for instance i want to choose first two,because in sum they have more then 96% of total variance,now please how can i continue for factor analysis?matlab commands also visual help will be very good,according to this answer

Steps done in factor analysis compared to steps done in PCA

i was confused,so please for given concrete numerical example,how can i continue,not just definitions,i need concrete numerical steps.thansk in advance

EDITED :
because i have choose first two eigenvector,i have done PCA also

factors=sorted(:,1:2)

factors =

    0.5080    0.5042
    0.0090   -0.6091
    0.8560   -0.3490
    0.0955    0.5030

>> PCA=X*factors

PCA =

  299.5739   24.8602
  150.1380   65.5846
  183.9319   36.7606
  156.7749   11.6325
   58.1864   17.0585
  236.6723   35.3584
  176.0291   68.7008
  208.4237   45.3761
  190.6039   33.7278
  206.2131    3.4430

how can i calculate loadings?how can i do orthogonal rotations?

Best Answer

Good news! You've allready calculated the loadings. The loadings are the weight each observation gets in the principal components. What you call 'factors' are the 'factor loadings'.

Rotations are performed on these 'loadings'=='eigenvectors'. The method to do this is dependent on the type of (ortoghonal) rotation you intend to do. The stats package has pca() and rotatefactors() (link) methods it that package is available to you.

Sidenote: I see that you calculated the eigenvectors with the covariance matrix, this assumes that all data is in the same scale. That is variations in Hours have the same impact as variations in Price. It might be more informative to use the eigenvalues of the correlation matrix corrcoef().

I also see that a lot of your coding is "reinventing the wheel" maybe thats intentional to learn but for example covariance matrices are built in in base via var(X) (link).

Good luck!