1
$\begingroup$

I saw this interesting topic: How to reverse PCA and reconstruct original variables from several principal components? and a nice answer with a very useful example of Iris data in Matlab. I would like to do the same using factor analysis instead of PCA. I tried to make it with 'factoran' of Matlab with the help of @ttnphns and @amoeba but I don't obtain a good correlation between my reconstructed data and the original ones.

input_data (*data are EMG measurement from 6 arm muscles in order to identify synergies)

PCA method:

X = input_data;
mu = mean(X);
[eigenvectors, scores] = pca(X);
nComp = 2;
Xpca = scores(:,1:nComp) * eigenvectors(:,1:nComp)';
Xpca = bsxfun(@plus, Xpca, mu);

I obtain good correlation between them.

FA method:

X = input_data;
mu = mean(X);
[LoadingsPM,specVarPM,rotationPM,stats, scores] = ...
                factoran(X,2,'rotate','promax');
Xfa = scores*LoadingsPM'; 
Xfa = bsxfun(@plus, Xfa, mu);

But in this case the correlations are bad. I don't know if I forget something? (I divided per 3 the FA reconstruction in order to see better the 3 curves).

enter image description here


@ttnphns note: word "reverse" in the title should be taken in the technical sense of computing variables as they are returned by the computed factors (their scores), - not in the theoretical sense (in which FA model is nothing but predicting variables by factors, so that there is no a "reverse" direction). In PCA, this prediction/direction indeed could be called "reverse" in a theoretical sense, too.

$\endgroup$
  • 1
    $\begingroup$ Factor analysis is all about "reconstructing" (predicting) variables by latent factors. It looks like you are a novice to FA and its distinction from PCA. Please take your time and read about FA first. I recommed you to read, carefully, not hastily this answer as the start. Then observe the difference in PCA and FA performed right on iris dataset. When you got understanding you will probably get concrete questions to ask here. $\endgroup$ – ttnphns Sep 12 '17 at 8:50
  • 1
    $\begingroup$ Upon reading the answer I've linked to you will understand why your question title How to reverse factor analysis (FA) and reconstruct original variables is incorrect. FA cannot be in reverse. It is PCA which can. FA reconstructs variables by factors - its only theoretical, model "direction". $\endgroup$ – ttnphns Sep 12 '17 at 9:25
  • 1
    $\begingroup$ @ttnphns Whether to call it "reverse" or not, one can perform a "reconstruction" of original variables by multiplying FA scores with FA loadings. In some sense it will be in "reverse" because FA loadings and scores have to be estimated from the original data. $\endgroup$ – amoeba says Reinstate Monica Sep 12 '17 at 10:20
  • 1
    $\begingroup$ @amoeba, Whether to call it "reverse" or not... Yes, of course, true, but it is trivial. It actually is doing with FA scores what we do with PCA scores. It is when we use F. scores in place of F. values in the factor model X_reconstr = F*Loadings. I just didn't think the OP is asking about that triviality. I thought they're asking about that reconstruction which is homologous, not superficially analogous, in FA to what we do in PCA. $\endgroup$ – ttnphns Sep 12 '17 at 10:39
  • 1
    $\begingroup$ floUDC, if you are asking about how factors or pr. components reconstruct correlations between variables, - they are reconstructed by multiplication of loadings (it is shown in my first link). Or do you want something else? Why do you need to reconstruct the variables themselves, what for? $\endgroup$ – ttnphns Sep 12 '17 at 10:52
2
$\begingroup$

@amoeba and @ttnphns have solved my problem in the comments. I posted the solution if someone is interested.

@amoeba:

Turns out, factoran implicitly standardizes all input variables and hence conducts FA on the correlation matrix (it's written in Help: "factoran standardizes the observed data X to zero mean and unit variance"). I could not find any input option that would turn off this behaviour. Hence, to do the "reconstruction", you need to compute stds = std(X); in the beginning and then to do Xfa = bsxfun(@times, Xfa, stds); after you multiplied scores by loadings and before adding the mean."

So the FA method corrected is:

X = input_data;
[LoadingsPM,specVarPM,rotationPM,stats, scores] = ...
                factoran(X,2,'rotate','promax');
Xfa = scores*LoadingsPM'; 
Xfa = bsxfun(@times, Xfa, std(X));
Xfa = bsxfun(@plus, Xfa, mean(X)); `

enter image description here

To complete this post, I recommend you this nice explanation made by @ttnphns: What are the differences between Factor Analysis and Principal Component Analysis?

$\endgroup$
  • $\begingroup$ +1, Good effort and nice acknowledgements. I would ask you, please to explain your graph right in your answer. What is shown as the curves and what are X Y axes. $\endgroup$ – ttnphns Sep 13 '17 at 10:06
  • 1
    $\begingroup$ You are right, I forgot the labels. I change it. It's a short try to identify muscular synergies. I recorded EMG measurements during extension then flexion of the arm which give me an easy example to start with this topic. So original data ara EMG measurements normalized in the time (10-2 s because I work at 100Hz). The objective is to reproduce the experimental data trying to find some strategies used by the central nervious system to the muscular activity. FA and PCA can underline some synergies between muscles group. $\endgroup$ – floUDC Sep 13 '17 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.