1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
*(Q) how to perform factor analysis with Spearman
	correlation thru a matrix.

*(A) Posted to SPSSX-L list on 2002/02/05 by Marta Garcia-Granero.


* 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.