How to perform a Direct Oblimin Rotation in MATLAB
Asked Answered
S

1

12

I'm trying to perform the following analysis in MATLAB:

Direct Oblimin Rotation with a Delta value of 0 and "Kaiser Normalization"

I know that MATLAB has a function called rotatefactors, however oblimin rotation is not mentioned (neither "Kaiser Normalization"). How can I perform this analysis in MATLAB?

To be more specific, I'm trying to match the exact output of SPSS when performing this analysis.

Here you can find all the algorithms used in SPSS: link (check the page 338 for the oblimin rotation). Unfortunately, I can't understand the equations and thus reproduce them in MATLAB.


As an example, I'm using the following data:

A = magic(10);
writetable(array2table(A),'test.xlsx') % This data can be imported to SPSS

I perform a PCA (on the correlation matrix) and extract only 2 factors. Here is how it is done in MATLAB in order to obtain the exact same Loading Matrix as in SPSS (which they call "Component Matrix"):

[eigvector,eigmatrix] = eig(corr(A));
[~,ind] = sort(diag(eigmatrix),'descend');
eigmatrix = eigmatrix(ind,ind);
eigvector = eigvector(:,ind);
eigvalues = diag(eigmatrix); % Eigeinvalues
loadings = eigvector*sqrt(eigmatrix);
loadings = loadings(:,1:2) % Extract only 2 factors

Next, I should perform the rotation on the loadings matrix using the function rotatefactors, and this is where I'm stuck.

Here is the syntax in SPSS:

FACTOR
/VARIABLES A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
/MISSING LISTWISE 
/ANALYSIS A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
/PRINT INITIAL EXTRACTION ROTATION
/CRITERIA FACTORS(2) ITERATE(25)
/EXTRACTION PC
/CRITERIA ITERATE(25) DELTA(0)
/ROTATION OBLIMIN
/METHOD=CORRELATION.

This is the output from SPSS which I'm trying to reproduce in MATLAB:

rotated ouput (SPSS)

Sogdiana answered 29/9, 2015 at 18:13 Comment(12)
and your question would be?Metagenesis
What is... oblimin rotation?Extravasation
@Benoit_11how to perform a direct oblimin rotation in MATLABSogdiana
@Extravasation I updated the post, have a look please!Sogdiana
Apparently you should implement it yourself :))Garris
@AliMirzaei I wish I could... I'll raise the bounty if no one answers! I really need thisSogdiana
You should define the mathematical objects used in the pdf you linked, i can help you but i won't read 300+ pages to get to the infos.Ferreby
Please use a non-random matrix as your example. We can't check if our output matches your output since we don't know what your original matrix was. Also, can you say more about where you're "stuck"? Doing B=rotatefactors(loadings) does give a 10-by-2 matrix... but I'm assuming it's not one of the two 10-by-2 matrices you're looking for....?Soffit
As I understood it OP wants the calculation made using OBLIMIN algorithm, which is not implemented in Matlab. Matlab does calculate the same thing though, even though it's not using the same convergence criterion/algrotihm.Ferreby
@Soffit I'll update my post to improve reproductibility. I'm stuck with the rotatefactors function, I don't know what parameters I've to use in order to carry out an OBLIMIN rotation (as specified in my post).Sogdiana
@Soffit I've updated my original postSogdiana
@Sogdiana : don't forget the bounty if my answer was useful to you ^^Ferreby
F
3

MATLAB doesn't have the OBLIMIN rotation method implemented yet, because the promax method does the same thing, only it is much much faster.

You'll not get the exact same output with this method compared to the SPSS OBLIMIN output, but they should be pretty close, as they're doing the same thing. (Actually, promax is also an oblique rotation, except it's first approximated by an orthogonal rotation before orthogonality is relaxed)

It might be possible to custom the orthogonal rotation inside the promax one, but I don't think you'll ever get the same output.

In order to do a promax rotation :

[B,T]=rotatefactors(loadings,'method','promax');

% Your pattern matrix is in B, to get the structure matrix, you can do :

S=B*inv(T'*T);

Note that rotations are defined modulo an angle pi, so you'll have an output matrix equal to +- what you want.

Running this on your example, one gets the pattern :

B =

   -0.0178    0.9765
   -0.9528    0.0563
   -0.0305   -1.0124
    0.9442   -0.0602
    0.9897   -0.0155
   -0.7625    0.1992
   -0.8823    0.0333
   -0.9776   -0.1919
   -0.7797    0.0719
    0.9950    0.0767

Along with the structure matrix :

S =

   -0.5740    0.9867
   -0.9849    0.5990
    0.5461   -0.9950
    0.9785   -0.5980
    0.9985   -0.5791
   -0.8760    0.6335
   -0.9013    0.5358
   -0.8683    0.3649
   -0.8206    0.5160
    0.9513   -0.4899

So, this is pretty close, but still different from the SPSS output.

We can see though, that the big differences are for pretty small values. As one is always taking the biggest values for the correlation analysis, it should not be that much of a problem.

Ferreby answered 5/10, 2015 at 14:17 Comment(5)
It is really close to what I was looking for but it's not yet exactly the same. I'll wait a few more days to see if there is a new response, otherwise I'll accept yours. Thank you!Sogdiana
@Adriaan : Sorry, english is not my native language, is 'cheers' too informal? What about the initials?Ferreby
They are what we call "fluff". It is not related to the question itself and thus is not necessary information here. The way to say "thank you" on SO is by using upvotes or accepting answers. This is to keep the text in the answer minimised to the information required to solve the problem. Sorry about not commenting this, I assumed you knew these SO-conventions, having 200 rep!Beckham
Thanks Adriaan, now i know!Ferreby
Part of the reason stuff like "I need help with...", "I don't know MATLAB, and I want ..." or "Thanks / Cheers" etc. is edited out is because it often shows up in search results. If you search for "How can I add two numbers?", you don't want to read: "Hi guys, I have a problem, and I have tried for hours. I really hope you can help me...", you want only the question and the answer... :) That aside; It's fine to add a little "cheers", or "hope that helped" in the end of an answer, but expect that it might be edited out by someone =)Cristinecristiona

© 2022 - 2024 — McMap. All rights reserved.