First, some dummy data to work with.
INPUT PROGRAM.
- VECTOR X(10).
- LOOP #I = 1 TO 100.
- LOOP #J = 1 TO 10.
- COMPUTE X(#J) = UNIFORM(5).
- END LOOP.
- END CASE.
- END LOOP.
- END FILE.
END INPUT PROGRAM.
execute.
* Creation of a correlation matrix suitable for FACTOR.
* It's a hybrid of two different files.
* If you stop and look at every step, you will see what the syntax does.
* A folder called temp must exist in the default drive.
* Original matrix files:
* Kendall correlation coeficients can also be used
* (for ordinal variables), instead of Spearman.
CORRELATIONS
/VARIABLES=x1 TO x10
/MATRIX=OUT('c:\temp\corr1_.sav')
/MISSING=PAIRWISE .
NONPAR CORR
/VARIABLES=x1 TO x10
/PRINT=SPEARMAN
/MATRIX=OUT('c:\temp\corr2_.sav')
/MISSING=PAIRWISE .
* Files manipulation.
GET FILE='c:\temp\corr2_.sav'.
EXECUTE .
SELECT IF(rowtype_ ~= 'N').
EXECUTE .
RECODE rowtype_ ('RHO'='CORR') .
EXECUTE .
SAVE OUTFILE='c:\temp\corr2_.sav'.
GET FILE='c:\temp\corr1_.sav'.
EXECUTE .
SELECT IF($casenum<4).
EXECUTE .
ADD FILES /FILE=*
/FILE='c:\temp\corr2_.sav'.
EXECUTE.
* Final matrix (suitable as input for FACTOR).
SAVE OUTFILE='c:\temp\c_matrix.sav'.
* Now, factor analysis:
* I have selected the options I normally use
* (KMO index, MSA, scree plot, Bartlett test,
* Varimax rotation with sorted and cleaned loadings)
* Modify them if needed.
FACTOR
/MATRIX=IN(cor='c:\temp\c_matrix.sav')
/ANALYSIS x1 TO x10
/PRINT KMO AIC EXTRACTION ROTATION
/FORMAT SORT BLANK(0.4)
/PLOT EIGEN
/CRITERIA MINEIGEN(1) ITERATE(25)
/EXTRACTION PC
/CRITERIA ITERATE(25)
/ROTATION VARIMAX
/METHOD=CORRELATION .
* Of course, these random data are uncorrelated, and no good for factor analysis,
* That's why KMO and MSA are low and Bartlett test is not significant.