C     CM-1                                                              CM1   1 
C     GIVEN AN RXC MATRIX OF REAL NUMBERS Y(I,J) DETERMINE A SET OF ROW CM1   2 
C     VALUES R(I) AND A SET OF COLUMN VALUES C(J) SUCH THAT X(I,J) =    CM1   3 
C     F(R(I),C(J)) AND X(I,J) IS MONOTONIC WITH Y(I,J) FOR NORMALIZED   CM1   4 
C     PHI, A MINIMUM.  THIS PROGRAM FOR CONJOINT MEASUREMENT WAS WRITTENCM1   5 
C     IN FORTRAN II BY J. C. LINGOES FOR THE UNIVERSITY OF MICHIGAN     CM1   6 
C     IBM-7090 COMPUTER.  THE GUTTMAN-LINGOES NONMETRIC SERIES RESEARCH CM1   7 
C     IS SUPPORTED IN PART BY A GRANT FROM THE NATIONAL SCIENCE FOUNDA- CM1   8 
C     TION (GS-929).  DATE = 1/15/67.                                   CM1   9 
C                                                                       CM1  10 
C     DECK SET-UP FOR G-L(CM-I) -                                       CM1  11 
C                                                                       CM1  12 
C        1.  SYSTEM ID CARD/S.                                          CM1  13 
C        2.  BINARY PROGRAM.                                            CM1  14 
C        3.  TITLE CARD (PUNCH A 1 IN COLUMN 1 AND ANY BCD TITLE IN COL-CM1  15 
C            UMNS 2-72 FOR OUTPUT LABELING).                            CM1  16 
C        4.  PARAMETER CARD, 3 4-COLUMN FIELDS CONTAINING THE FOLLOWING CM1  17 
C            INFORMATION SERIATUM-                                      CM1  18 
C            A)  NR=NUMBER OF ROWS OF INPUT MATRIX (NR .LE. 50),        CM1  19 
C            B)  NC=NUMBER OF COLUMNS (NC .LE. 50),                     CM1  20 
C            C)  M=1 IF ADDITIVE MODEL DESIRED, OR                      CM1  21 
C                M=2 IF SUBTRACTIVE MODEL, OR                           CM1  22 
C                M=3 IF QUADRATIC-ADDITIVE, OR                          CM1  23 
C                M=4 IF CUBIC-ADDITIVE,OR                               CM1  24 
C                M=5 IF COMPLEX MODEL (SUPPLIED BY A USER'S MODIFICATIONCM1  25 
C                    OF THE FUNCTION SUBROUTINE), OR                    CM1  26 
C                M=0 IF MODELS 1-4 ARE TO BE TRIED IN SEQUENCE.         CM1  27 
C        5.  FORMAT CARD (DESCRIBING IN F-NOTATION HOW DATA HAS BEEN    CM1  28 
C            PUNCHED).                                                  CM1  29 
C        6.  DATA (PUNCH VALUES OF Y, WHERE EACH SET OF CARDS REPRESENTSCM1  30 
C            A ROW OF MATRIX AND THE FIELDS REPRESENT COLUMNAR ENTRIES).CM1  31 
C                                                                       CM1  32 
C        *** REFERENCES - LINGOES, J.C.  AN IBM-7090 PROGRAM FOR GUTTMANCM1  33 
C                           -LINGOES CONJOINT MEASUREMENT - I.  BEHAV.  CM1  34 
C                           SCI.,1967,12,501-502.                       CM1  35 
C                                                                       CM1  36 
C        *** OBSERVE STARRED COMMENT CARDS FOR CONVERSIONS TO OTHER     CM1  37 
C            SYSTEMS ***                                                CM1  38 
C                                                                       CM1  39 
      DIMENSION FMT(18), Y(50,50), X(50,50), INDY(2500), INDX(2500), RCICM1  40 
     1(100), RCF(100), XSTAR(50,50), CM(50,50)                          CM1  41 
      COMMON Y,X,INDY,INDX,RCI,RCF,XSTAR,CM                             CM1  42 
C                                                                       CM1  43 
C     SUBROUTINES NEEDED=RADIX SORT                                     CM1  44 
C                                                                       CM1  45 
C     *** TAPE ASSIGNMENTS                                              CM1  46 
      ITAPE=5                                                           CM1  47 
      JTAPE=6                                                           CM1  48 
C     INPUT TITLE, PARAMETERS, AND DATA                                 CM1  49 
1     READ (ITAPE,42)                                                   CM1  50 
      READ (ITAPE,43) NR,NC,M                                           CM1  51 
      READ (ITAPE,44) (FMT(J),J=1,18)                                   CM1  52 
      DO 2 I=1,NR                                                       CM1  53 
2     READ (ITAPE,FMT) (Y(I,J),J=1,NC)                                  CM1  54 
C     COMPUTE INITIAL VALUES FOR R AND C AND INITIALIZE                 CM1  55 
      N=NR*NC                                                           CM1  56 
      MM=0                                                              CM1  57 
      K=NR+NC                                                           CM1  58 
      NRP1=NR+1                                                         CM1  59 
      FNR=NR                                                            CM1  60 
      FNC=NC                                                            CM1  61 
      FN=N                                                              CM1  62 
      ASSIGN 16 TO N1                                                   CM1  63 
      S=0.                                                              CM1  64 
      SS=0.                                                             CM1  65 
      II=0                                                              CM1  66 
      JJ=0                                                              CM1  67 
      DO 4 I=1,NR                                                       CM1  68 
      JJ=JJ+1                                                           CM1  69 
      RCI(JJ)=0.                                                        CM1  70 
      DO 3 J=1,NC                                                       CM1  71 
      II=II+1                                                           CM1  72 
      X(II,1)=Y(I,J)                                                    CM1  73 
      RCI(JJ)=RCI(JJ)+X(II,1)                                           CM1  74 
3     SS=SS+X(II,1)**2                                                  CM1  75 
      S=S+RCI(JJ)                                                       CM1  76 
4     RCI(JJ)=RCI(JJ)/FNC                                               CM1  77 
      DO 6 J=1,NC                                                       CM1  78 
      JJ=JJ+1                                                           CM1  79 
      RCI(JJ)=0.                                                        CM1  80 
      DO 5 I=1,NR                                                       CM1  81 
5     RCI(JJ)=RCI(JJ)+Y(I,J)                                            CM1  82 
6     RCI(JJ)=RCI(JJ)/FNR                                               CM1  83 
      SS=SQRT(FN*SS-S**2)                                               CM1  84 
C     *** A FAST RADIX SORT SHOULD BE CALLED UPON ***                   CM1  85 
C     *** USE THE SORT SUBROUTINE OF G-L(SSA-III) ***                   CM1  86 
      CALL SORT (-1,N,X,1,INDY)                                         CM1  87 
C     TEST MODEL-M BASED UPON INITIAL VALUES                            CM1  88 
      IF (M) 8,7,8                                                      CM1  89 
7     MM=MM+1                                                           CM1  90 
      IF (MM-5) 9,1,9                                                   CM1  91 
8     MM=M                                                              CM1  92 
9     ITER=1                                                            CM1  93 
      PRER=1.                                                           CM1  94 
      DO 10 J=1,K                                                       CM1  95 
10    RCF(J)=RCI(J)                                                     CM1  96 
C     GENERATE X AS A FUNCTION OF R AND C                               CM1  97 
      CALL RCFUNC (-1,NR,NC,MM,RCF,X)                                   CM1  98 
      GO TO 12                                                          CM1  99 
11    ITER=ITER+1                                                       CM1 100 
C     CALL FUNCTION SUBROUTINE                                          CM1 101 
      CALL RCFUNC (0,0,0,0,RCF,X)                                       CM1 102 
C     OBTAIN BEST LINEAR FIT TO Y                                       CM1 103 
12    A=0.                                                              CM1 104 
      B=0.                                                              CM1 105 
      C=0.                                                              CM1 106 
      II=0                                                              CM1 107 
      DO 13 I=1,NR                                                      CM1 108 
      DO 13 J=1,NC                                                      CM1 109 
      II=II+1                                                           CM1 110 
      A=A+X(II,1)                                                       CM1 111 
      B=B+X(II,1)**2                                                    CM1 112 
13    C=C+X(II,1)*Y(I,J)                                                CM1 113 
      D=FN*B-A**2                                                       CM1 114 
      IF (D) 40,40,14                                                   CM1 115 
14    E=(FN*C-A*S)/D                                                    CM1 116 
      F=(B*S-C*A)/D                                                     CM1 117 
      DO 15 J=1,N                                                       CM1 118 
15    X(J,1)=E*X(J,1)+F                                                 CM1 119 
      GO TO N1, (16,17)                                                 CM1 120 
C     CALL SORT SUBROUTINE                                              CM1 121 
16    CALL SORT (0,0,X,1,INDX)                                          CM1 122 
      ASSIGN 17 TO N1                                                   CM1 123 
      GO TO 18                                                          CM1 124 
C     CALL SORT SUBROUTINE                                              CM1 125 
17    CALL SORT (1,0,X,1,INDX)                                          CM1 126 
C     OBTAIN RANK-IMAGES                                                CM1 127 
18    DO 19 J=1,N                                                       CM1 128 
      II=INDY(J)                                                        CM1 129 
      JJ=INDX(J)                                                        CM1 130 
19    XSTAR(II,1)=X(JJ,1)                                               CM1 131 
C     COMPUTE PRODUCT MOMENT CORRELATION BETWEEN X AND XSTAR            CM1 132 
      A=0.                                                              CM1 133 
      B=0.                                                              CM1 134 
      C=0.                                                              CM1 135 
      DO 20 J=1,N                                                       CM1 136 
      C=C+X(J,1)                                                        CM1 137 
      B=B+X(J,1)**2                                                     CM1 138 
20    A=A+X(J,1)*XSTAR(J,1)                                             CM1 139 
      A=FN*A                                                            CM1 140 
      B=FN*B                                                            CM1 141 
      B=B-C**2                                                          CM1 142 
      IF (B) 40,40,21                                                   CM1 143 
21    A=(A-C**2)/B                                                      CM1 144 
      PHI=SQRT(ABS(1.-A**2))                                            CM1 145 
C     TEST FOR TERMINATION                                              CM1 146 
      IF (PHI-1E-03) 30,30,22                                           CM1 147 
22    IF (ABS(PHI-PRER)-1E-06) 30,23,23                                 CM1 148 
23    PRER=PHI                                                          CM1 149 
      IF (ITER-1000) 24,30,24                                           CM1 150 
C     OBTAIN NEXT SET OF R(I) AND C(J)                                  CM1 151 
24    JJ=0                                                              CM1 152 
      DO 25 I=1,NR                                                      CM1 153 
      DO 25 J=1,NC                                                      CM1 154 
      JJ=JJ+1                                                           CM1 155 
25    CM(I,J)=XSTAR(JJ,1)                                               CM1 156 
      JJ=0                                                              CM1 157 
      DO 27 I=1,NR                                                      CM1 158 
      JJ=JJ+1                                                           CM1 159 
      RCF(JJ)=0.                                                        CM1 160 
      DO 26 J=1,NC                                                      CM1 161 
26    RCF(JJ)=RCF(JJ)+CM(I,J)                                           CM1 162 
27    RCF(JJ)=RCF(JJ)/FNC                                               CM1 163 
      DO 29 J=1,NC                                                      CM1 164 
      JJ=JJ+1                                                           CM1 165 
      RCF(JJ)=0.                                                        CM1 166 
      DO 28 I=1,NR                                                      CM1 167 
28    RCF(JJ)=RCF(JJ)+CM(I,J)                                           CM1 168 
29    RCF(JJ)=RCF(JJ)/FNR                                               CM1 169 
      GO TO 11                                                          CM1 170 
C     CORRELATE Y AND X                                                 CM1 171 
30    D=0.                                                              CM1 172 
      JJ=0                                                              CM1 173 
      DO 31 I=1,NR                                                      CM1 174 
      DO 31 J=1,NC                                                      CM1 175 
      JJ=JJ+1                                                           CM1 176 
31    D=D+Y(I,J)*X(JJ,1)                                                CM1 177 
      B=SQRT(B)                                                         CM1 178 
      D=FN*D                                                            CM1 179 
      B=(D-S*C)/(SS*B)                                                  CM1 180 
C     PRINT OUT RESULTS                                                 CM1 181 
      WRITE (JTAPE,42)                                                  CM1 182 
      WRITE (JTAPE,45)                                                  CM1 183 
      GO TO (32,33,34,35,36), MM                                        CM1 184 
32    WRITE (JTAPE,46) E,F                                              CM1 185 
      GO TO 37                                                          CM1 186 
33    WRITE (JTAPE,47) E,F                                              CM1 187 
      GO TO 37                                                          CM1 188 
34    WRITE (JTAPE,48) E,F                                              CM1 189 
      GO TO 37                                                          CM1 190 
35    WRITE (JTAPE,49) E,F                                              CM1 191 
      GO TO 37                                                          CM1 192 
36    WRITE (JTAPE,50) E,F                                              CM1 193 
37    JJ=0                                                              CM1 194 
      DO 38 I=1,NR                                                      CM1 195 
      DO 38 J=1,NC                                                      CM1 196 
      JJ=JJ+1                                                           CM1 197 
38    CM(I,J)=X(JJ,1)                                                   CM1 198 
      DO 39 I=1,NR                                                      CM1 199 
      WRITE (JTAPE,51) I,RCF(I),(CM(I,J),J=1,NC)                        CM1 200 
39    WRITE (JTAPE,52) (Y(I,L),L=1,NC)                                  CM1 201 
      WRITE (JTAPE,53) (RCF(J),J=NRP1,K)                                CM1 202 
      WRITE (JTAPE,54) B,PHI,ITER                                       CM1 203 
      GO TO 41                                                          CM1 204 
40    WRITE (JTAPE,55)                                                  CM1 205 
41    IF (M) 1,7,1                                                      CM1 206 
C     *** FORMAT STATEMENTS ***                                         CM1 207 
C                                                                       CM1 208 
42    FORMAT (72H                                                       CM1 209 
     1                 )                                                CM1 210 
43    FORMAT (3I4)                                                      CM1 211 
44    FORMAT (18A4)                                                     CM1 212 
45    FORMAT (48X36HGUTTMAN-LINGOES CONJOINT MEASUREMENT/57X18HPAIRED X'CM1 213 
     1S AND Y'S/1H ,131(1H-))                                           CM1 214 
46    FORMAT (32H0MODEL IS ADDITIVE,I.E.,X(I,J) =,E13.6,15H(R(I) + C(J))CM1 215 
     1 +,E13.6)                                                         CM1 216 
47    FORMAT (35H0MODEL IS SUBTRACTIVE,I.E.,X(I,J) =,E13.6,17H(/R(I) - CCM1 217 
     1(J)/) +,E13.6)                                                    CM1 218 
48    FORMAT (42H0MODEL IS QUADRATIC-ADDITIVE,I.E.,X(I,J) =,E13.6,35H(R(CM1 219 
     1I)**2 + C(J)**2 + R(I) * C(J)) +,E13.6)                           CM1 220 
49    FORMAT (38H0MODEL IS CUBIC-ADDITIVE,I.E.,X(I,J) =,E13.6,55H(R(I)**CM1 221 
     13 + C(J)**3 + R(I)**2 * C(J) + R(I) * C(J)**2) +,E13.6)           CM1 222 
50    FORMAT (30H0MODEL IS USER'S,I.E.,X(I,J) =,E13.6,15H*F(R(I),C(J)) +CM1 223 
     1,E13.6)                                                           CM1 224 
51    FORMAT (2H0R,I2,2H =,F11.3,5H X = ,10F11.3/(22X10F11.3))          CM1 225 
52    FORMAT (1H0,16X5H Y = ,10F11.3/(22X10F11.3))                      CM1 226 
53    FORMAT (7H0C(J) =,15X10F11.3/(22X10F11.3))                        CM1 227 
54    FORMAT (9H0R(X,Y) =,F6.3/49H COEFFICIENT OF ALIENATION = SQRT(1-R(CM1 228 
     1X*,X)**2) =,E13.6,5H FOR ,I5,12H ITERATIONS.)                     CM1 229 
55    FORMAT (42H1*** PRESENT SOLUTION IS INDETERMINATE ***)            CM1 230 
      END                                                               CM1 231-
C     RCFUNC                                                            RCF   1 
C     THIS PROGRAM GENERATES AN RXC MATRIX OF VALUES WHICH ARE A        RCF   2 
C     FUNCTION OF R(I) AND C(J).                                        RCF   3 
C                                                                       RCF   4 
      SUBROUTINE RCFUNC (ISET,NRO,NCOL,IFUNC,VEC,VAL)                   RCF   5 
      DIMENSION VEC(1), VAL(1)                                          RCF   6 
C                                                                       RCF   7 
      IF (ISET) 1,2,1                                                   RCF   8 
1     N=NRO                                                             RCF   9 
      K=NCOL                                                            RCF  10 
      M=IFUNC                                                           RCF  11 
      NP1=N+1                                                           RCF  12 
      NPK=N+K                                                           RCF  13 
2     JJ=0                                                              RCF  14 
      DO 8 I=1,N                                                        RCF  15 
      DO 8 J=NP1,NPK                                                    RCF  16 
      JJ=JJ+1                                                           RCF  17 
      GO TO (3,4,5,6,7), M                                              RCF  18 
3     VAL(JJ)=VEC(I)+VEC(J)                                             RCF  19 
      GO TO 8                                                           RCF  20 
4     VAL(JJ)=ABS(VEC(I)-VEC(J))                                        RCF  21 
      GO TO 8                                                           RCF  22 
5     VAL(JJ)=VEC(I)**2+VEC(J)**2+VEC(I)*VEC(J)                         RCF  23 
      GO TO 8                                                           RCF  24 
6     VAL(JJ)=VEC(I)*VEC(J)**2+VEC(J)*VEC(I)**2+VEC(I)*VEC(I)**2+VEC(J)*RCF  25 
     1VEC(J)**2                                                         RCF  26 
      GO TO 8                                                           RCF  27 
C     *** THE USER SHOULD SUPPLY HIS OWN FUNCTION STATEMENT FOR THE     RCF  28 
C     DUMMY ONE OF STATEMENT 7 ***                                      RCF  29 
7     VAL(JJ)=VAL(JJ)                                                   RCF  30 
8     CONTINUE                                                          RCF  31 
      RETURN                                                            RCF  32 
      END                                                               RCF  33-
1TEST OF ADDITIVE MODEL (1,2,3,4,5,6,7)                                         
   3   4                                                                        
(4F2.0)                                                                         
 5 6 7 8                                                                        
 6 7 8 9                                                                        
 7 8 910                                                                        
1ADDITIVE TEST WITH UNCORRELATED ERROR COMPONENT WHOSE MEAN = 0                 
   3   4   0                                                                    
(4F3.2)                                                                         
550540500975                                                                    
660630720810                                                                    
770880990975                                                                    
1TEST OF ERROR COMPONENT - MODEL UNKNOWN                                        
   3   4   0                                                                    
(4F4.2)                                                                         
  50 -60-200 175                                                                
  60 -70 -80 -90                                                                
  70  80  90 -25                                                                
1TEST OF ADDITIVE MODEL (1,2,3/-4,-5,-6,-7)                                     
   3   4   0                                                                    
(4F2.0)                                                                         
-3-4-5-6                                                                        
-2-3-4-5                                                                        
-1-2-3-4                                                                        
1TEST OF SUBTRACTIVE MODEL (1,2,3,4,5,6,7)                                      
   3   4   0                                                                    
(4F2.0)                                                                         
 3 4 5 6                                                                        
 2 3 4 5                                                                        
 1 2 3 4                                                                        
1TEST OF MULTIPLICATIVE MODEL (1,2,3,4,5,6,7)                                   
   3   4                                                                        
(4F2.0)                                                                         
 4 5 6 7                                                                        
 8101214                                                                        
12151821                                                                        
1TEST OF QUADRATIC-ADDITIVE MODEL (1,2,3,4,5,6,7)                               
   3   4                                                                        
(4F2.0)                                                                         
17263750                                                                        
20294053                                                                        
25344558                                                                        
1TEST OF MULTIPLICATIVE MODEL (-2,3,-9,-5,8,-2,11)                              
   4   3                                                                        
(4F3.0)                                                                         
-16  4-22                                                                       
 24 -6 33                                                                       
-72 18-99                                                                       
-40 10-55                                                                       
