C     CM-2                                                              CM2   1 
C     GIVEN A DEPENDENT VARIABLE Y AND A MATRIX OF INDEPENDENT VARIABLESCM2   2 
C     X, DETERMINE A SET OF WEIGHTS (1 FOR EACH OBSERVATION), SUCH THAT CM2   3 
C     MEAN R(W*,X*) IS A MAXIMUM SUBJECT TO THE CONSTRAINTS THAT W* IS ACM2   4 
C     MONOTONE TRANSFORMATION OF Y AND X* IS MONOTONICALLY RELATED TO X,CM2   5 
C     FOR EACH VARIABLE SEPARATELY FOR R(W,W*) A MAXIMUM.  THIS PROGRAM CM2   6 
C     IS DESIGNED FOR NONMETRIC GENERALIZED MULTIPLE REGRESSION ANALYSISCM2   7 
C     AND WAS PROGRAMMED IN FORTRAN II BY J.C. LINGOES FOR THE UNIVERSI-CM2   8 
C     TY OF MICHIGAN IBM-7090 COMPUTER.  THE GUTTMAN-LINGOES NONMETRIC  CM2   9 
C     SERIES RESEARCH IS SUPPORTED IN PART BY A GRANT FROM THE NATIONAL CM2  10 
C     SCIENCE FOUNDATION (GS-929).  DATE = 5/1/67.                      CM2  11 
C                                                                       CM2  12 
C     DECK SET-UP FOR G-L(CM-II) -                                      CM2  13 
C                                                                       CM2  14 
C        1.  SYSTEM ID CARD/S.                                          CM2  15 
C        2.  BINARY PROGRAM.                                            CM2  16 
C        3.  TITLE CARD FOR HEADING (PUNCH A 1 IN COL. 1 AND ANY BCD    CM2  17 
C            TITLE IN COLS. 2-72).                                      CM2  18 
C        4.  PARAMETER CARD, 7 4-COLUMN FIELDS CONTAINING THE FOLLOWING CM2  19 
C            INFORMATION SERIATUM -                                     CM2  20 
C            A)  NS=NUMBER OF OBSERVATIONS (NS .LE. 200),               CM2  21 
C            B)  NV=NUMBER OF VARIABLES INCLUDING Y (NV  .LE.  25),     CM2  22 
C            C)  ICARDS=1 IF CARD OUTPUT DESIRED AND ZERO OR BLANK,     CM2  23 
C                OTHERWISE.  S SEQUENCE NUMBER IS PUNCHED FIRST, THEN X*CM2  24 
C                AND FINALLY, Y* FOR EACH OBSERVATION,                  CM2  25 
C            D)  MISS=1 IF MISSING DATA EXISTS FOR 1 OR MORE INDEPENDENTCM2  26 
C                VARIABLES, OTHERWISE SET TO ZERO OR LEAVE BLANK.  IF   CM2  27 
C                MISSING DATA EXISTS FOR THE DEPENDENT VARIABLE, HOWEVERCM2  28 
C                , THOSE OBSERVATIONS MUST BE DELETED,                  CM2  29 
C            E)  CODE=SOME NUMERIC VALUE THAT IS UNIFORM FOR ALL VARIA- CM2  30 
C                BLES AND OBSERVATIONS DENOTING AN UNKNOWN SCORE (DO    CM2  31 
C                NOT USE A VALUE REPRESENTING A LEGITIMATE SCORE.  DECI-CM2  32 
C                MAL POINT MUST BE PUNCHED.)  IF NO MISSING DATA, LEAVE CM2  33 
C                BLANK,                                                 CM2  34 
C            F)  CK=MINIMUM VALUE DESIRED FOR K=SQRT(1-R**2(W,W*)), THE CM2  35 
C                G-L COEFFICIENT OF ALIENATION ACCORDING TO FORMAT F4.4,CM2  36 
C                (DO NOT PUNCH DECIMAL POINT.),                         CM2  37 
C            G)  Z=MAXIMUM CONTRIBUTION THAT ANY ONE S CAN CONTRIBUTE TOCM2  38 
C                ANY CORRELATION ACCORDING TO FORMAT F4.4 (DO NOT PUNCH CM2  39 
C                DECIMAL POINT).  IF FIELD LEFT BLANK Z=.5000.  RECOM-  CM2  40 
C                MENDED VALUE FOR Z, IN GENERAL, IS 5/NS IF COMMENT IS  CM2  41 
C                PRINTED OUT THAT SOME OBSERVATION IS AN OUTLIER.       CM2  42 
C        5.  FORMAT (DESCRIBING IN F-FORMAT HOW DATA HAS BEEN PUNCHED). CM2  43 
C        6.  DATA (PUNCH Y THEN X'S FOR EACH S, WHERE EACH CARD OR SET  CM2  44 
C            OF CARDS REPRESENTS 1 S AND EACH FIELD A VARIABLE IN COLS. CM2  45 
C            1-72.  73-80 MAY OPTIONALLY BE USED FOR ID INFORMATION).   CM2  46 
C        7.  REPEAT ITEMS 3-6 FOR ADDITONAL RUNS.                       CM2  47 
C                                                                       CM2  48 
C     *** REFERENCES - LINGOES, J.C.,  AN IBM-7090 PROGRAM FOR          CM2  49 
C                          GUTTMAN-LINGOES CONJOINT MEASUREMENT - II.   CM2  50 
C                          BEHAV. SCI., 1968, 13,                       CM2  51 
C                                                                       CM2  52 
C     *** OBSERVE STARRED COMMENT CARDS FOR CONVERSIONS TO OTHER        CM2  53 
C            SYSTEMS ***                                                CM2  54 
C                                                                       CM2  55 
      DIMENSION FMT(18), YX(200,25), INDI(200,25), W(200), WX(200,25), ICM2  56 
     1NDJ(200,25), NT(25), NOTIES(100,25)                               CM2  57 
      COMMON YX,INDI,WX,INDJ,NOTIES                                     CM2  58 
C                                                                       CM2  59 
C     SUBROUTINES NEEDED=ORDER                                          CM2  60 
C                                                                       CM2  61 
C     TAPE ASSIGNMENTS -                                                CM2  62 
      ITAPE=5                                                           CM2  63 
      JTAPE=6                                                           CM2  64 
C     INPUT TITLE, PARAMETERS, AND DATA                                 CM2  65 
1     READ (ITAPE,70)                                                   CM2  66 
      READ (ITAPE,71) NS,NV,ICARDS,MISS,CODE,CK,Z                       CM2  67 
      READ (ITAPE,72) (FMT(J),J=1,18)                                   CM2  68 
      DO 2 I=1,NS                                                       CM2  69 
2     READ (ITAPE,FMT) (YX(I,J),J=1,NV)                                 CM2  70 
C     CHECK FOR MISSING DATA AND SUBSTITUTE MEANS                       CM2  71 
      IF (MISS) 3,9,3                                                   CM2  72 
3     DO 8 J=2,NV                                                       CM2  73 
      A=0.                                                              CM2  74 
      B=0.                                                              CM2  75 
      DO 5 I=1,NS                                                       CM2  76 
      IF (YX(I,J)-CODE) 4,5,4                                           CM2  77 
4     A=A+YX(I,J)                                                       CM2  78 
      B=B+1.                                                            CM2  79 
5     CONTINUE                                                          CM2  80 
      A=A/B                                                             CM2  81 
      DO 7 I=1,NS                                                       CM2  82 
      IF (YX(I,J)-CODE) 7,6,7                                           CM2  83 
6     YX(I,J)=A                                                         CM2  84 
7     CONTINUE                                                          CM2  85 
8     CONTINUE                                                          CM2  86 
C     CONVERT SCORES TO UNITARY STANDARD MEASURE                        CM2  87 
9     FN=NS                                                             CM2  88 
      IF (Z) 11,10,11                                                   CM2  89 
10    Z=SQRT(FN*.5)                                                     CM2  90 
      GO TO 12                                                          CM2  91 
11    Z=SQRT(FN*Z)                                                      CM2  92 
12    DO 14 J=1,NV                                                      CM2  93 
      W(J)=0.                                                           CM2  94 
      WX(J,1)=0.                                                        CM2  95 
      DO 13 I=1,NS                                                      CM2  96 
      W(J)=W(J)+YX(I,J)                                                 CM2  97 
13    WX(J,1)=WX(J,1)+YX(I,J)**2                                        CM2  98 
      W(J)=W(J)/FN                                                      CM2  99 
      WX(J,1)=SQRT(WX(J,1)/FN-W(J)**2)                                  CM2 100 
      DO 14 K=1,NS                                                      CM2 101 
14    YX(K,J)=(YX(K,J)-W(J))/WX(J,1)                                    CM2 102 
C     PRINT OUT MEANS AND STANDARD DEVIATIONS                           CM2 103 
      WRITE (JTAPE,70)                                                  CM2 104 
      WRITE (JTAPE,73) (W(J),J=1,NV)                                    CM2 105 
      WRITE (JTAPE,74) (WX(J,1),J=1,NV)                                 CM2 106 
C     DETERMINE CORRELATIONS WITH DEPENDENT VARIABLE AND OPTIMALLY      CM2 107 
C     REFLECT INDEPENDENT VARIABLES                                     CM2 108 
      DO 18 J=2,NV                                                      CM2 109 
      W(J)=0.                                                           CM2 110 
      DO 15 I=1,NS                                                      CM2 111 
15    W(J)=W(J)+YX(I,1)*YX(I,J)                                         CM2 112 
      W(J)=W(J)/FN                                                      CM2 113 
      IF (W(J)) 16,18,18                                                CM2 114 
16    DO 17 K=1,NS                                                      CM2 115 
17    YX(K,J)=-YX(K,J)                                                  CM2 116 
18    CONTINUE                                                          CM2 117 
C     PRINT OUT CORRELATIONS WITH DEPENDENT VARIABLE                    CM2 118 
      WRITE (JTAPE,75) (W(J),J=2,NV)                                    CM2 119 
      FNV=NV-1                                                          CM2 120 
C     ORDER DEPENDENT VARIABLE AND INDEPENDENT VARIABLES                CM2 121 
C     *** USE ORDER SUBROUTINE ***                                      CM2 122 
      CALL ORDER (-1,NS,YX,1,INDI)                                      CM2 123 
      DO 19 J=2,NV                                                      CM2 124 
19    CALL ORDER (0,0,YX(1,J),1,INDI(1,J))                              CM2 125 
C     DETERMINE IF TIES EXIST                                           CM2 126 
      NOT=0                                                             CM2 127 
      DO 26 J=1,NV                                                      CM2 128 
      NT(J)=0                                                           CM2 129 
      JJ=1                                                              CM2 130 
      II=-1                                                             CM2 131 
      KK=JJ                                                             CM2 132 
20    LL=1                                                              CM2 133 
      MM=INDI(JJ,J)                                                     CM2 134 
21    KK=KK+1                                                           CM2 135 
      NN=INDI(KK,J)                                                     CM2 136 
      IF (YX(MM,J)-YX(NN,J)) 23,22,23                                   CM2 137 
22    LL=LL+1                                                           CM2 138 
      NOT=NOT+1                                                         CM2 139 
      IF (KK-NS) 21,24,24                                               CM2 140 
23    IF (LL-2) 25,24,24                                                CM2 141 
24    II=II+2                                                           CM2 142 
      NT(J)=NT(J)+2                                                     CM2 143 
      NOTIES(II,J)=LL                                                   CM2 144 
      NOTIES(II+1,J)=JJ                                                 CM2 145 
25    JJ=KK                                                             CM2 146 
      IF (JJ-NS) 20,26,26                                               CM2 147 
26    CONTINUE                                                          CM2 148 
      ITER=0                                                            CM2 149 
      PRER=1.                                                           CM2 150 
      ASSIGN 31 TO N1                                                   CM2 151 
      ASSIGN 48 TO N2                                                   CM2 152 
      DO 27 I=1,NS                                                      CM2 153 
27    W(I)=YX(I,1)                                                      CM2 154 
28    ITER=ITER+1                                                       CM2 155 
      DO 30 I=1,NS                                                      CM2 156 
      WX(I,1)=0.                                                        CM2 157 
      DO 29 J=2,NV                                                      CM2 158 
29    WX(I,1)=WX(I,1)+YX(I,J)                                           CM2 159 
30    WX(I,1)=WX(I,1)/FNV                                               CM2 160 
C     SORT WX(I,1) AND PERMUTE TO ORDER OF Y(I)                         CM2 161 
      GO TO N1, (31,32)                                                 CM2 162 
31    CALL ORDER (0,0,WX,1,INDJ)                                        CM2 163 
      ASSIGN 32 TO N1                                                   CM2 164 
      GO TO 33                                                          CM2 165 
32    CALL ORDER (1,0,WX,1,INDJ)                                        CM2 166 
C     COMPUTE RANK-IMAGES OF Y                                          CM2 167 
33    DO 34 I=1,NS                                                      CM2 168 
      II=INDI(I,1)                                                      CM2 169 
      JJ=INDJ(I,1)                                                      CM2 170 
34    YX(II,1)=WX(JJ,1)                                                 CM2 171 
C     COMPUTE COEFFICIENT OF ALIENATION AND TEST FOR TERMINATION        CM2 172 
      PHI=0.                                                            CM2 173 
      CAL=0.                                                            CM2 174 
      DO 35 I=1,NS                                                      CM2 175 
      PHI=PHI+YX(I,1)*WX(I,1)                                           CM2 176 
35    CAL=CAL+WX(I,1)**2                                                CM2 177 
      CAL=PHI/CAL                                                       CM2 178 
      CAL=SQRT(ABS(1.-CAL**2))                                          CM2 179 
C     TIE Y VALUES IF TIES EXIST                                        CM2 180 
      IF (NT(1)) 36,40,36                                               CM2 181 
36    KK=NT(1)                                                          CM2 182 
      DO 39 I=1,KK,2                                                    CM2 183 
      LL=NOTIES(I,1)                                                    CM2 184 
      MM=NOTIES(I+1,1)                                                  CM2 185 
      NN=MM                                                             CM2 186 
      A=0.                                                              CM2 187 
      DO 37 K=1,LL                                                      CM2 188 
      JJ=INDI(NN,1)                                                     CM2 189 
      A=A+YX(JJ,1)                                                      CM2 190 
37    NN=NN+1                                                           CM2 191 
      NN=MM                                                             CM2 192 
      A=A/FLOAT(LL)                                                     CM2 193 
      DO 38 L=1,LL                                                      CM2 194 
      JJ=INDI(NN,1)                                                     CM2 195 
      YX(JJ,1)=A                                                        CM2 196 
38    NN=NN+1                                                           CM2 197 
39    CONTINUE                                                          CM2 198 
40    IF (CAL-CK) 61,41,41                                              CM2 199 
41    IF (ABS(CAL-PRER)-1E-06) 61,42,42                                 CM2 200 
42    PRER=CAL                                                          CM2 201 
      IF (ITER-100) 43,61,43                                            CM2 202 
C     COMPUTE WEIGHTED SCORES                                           CM2 203 
43    DO 44 I=1,NS                                                      CM2 204 
      DO 44 J=2,NV                                                      CM2 205 
44    WX(I,J)=YX(I,J)+YX(I,1)                                           CM2 206 
C     NORMALIZE WEIGHTED SCORES                                         CM2 207 
      DO 46 J=2,NV                                                      CM2 208 
      A=0.                                                              CM2 209 
      DO 45 I=1,NS                                                      CM2 210 
45    A=A+WX(I,J)**2                                                    CM2 211 
      A=SQRT(FN/A)                                                      CM2 212 
      DO 46 K=1,NS                                                      CM2 213 
46    WX(K,J)=WX(K,J)*A                                                 CM2 214 
      DO 47 J=2,NV                                                      CM2 215 
      DO 47 I=1,NS                                                      CM2 216 
      IF (ABS(WX(I,J))-Z) 47,60,60                                      CM2 217 
47    CONTINUE                                                          CM2 218 
C     SORT NORMALIZED WEIGHTED SCORES AND PERMUTE TO ORDER OF X(I,J)    CM2 219 
      GO TO N2, (48,50)                                                 CM2 220 
48    DO 49 J=2,NV                                                      CM2 221 
49    CALL ORDER (0,0,WX(1,J),1,INDJ(1,J))                              CM2 222 
      ASSIGN 50 TO N2                                                   CM2 223 
      GO TO 52                                                          CM2 224 
50    DO 51 J=2,NV                                                      CM2 225 
51    CALL ORDER (1,0,WX(1,J),1,INDJ(1,J))                              CM2 226 
C     COMPUTE RANK-IMAGES OF X                                          CM2 227 
52    DO 53 J=2,NV                                                      CM2 228 
      DO 53 I=1,NS                                                      CM2 229 
      II=INDI(I,J)                                                      CM2 230 
      JJ=INDJ(I,J)                                                      CM2 231 
53    YX(II,J)=WX(JJ,J)                                                 CM2 232 
C     TIE X VALUES IF TIES EXIST                                        CM2 233 
      IF (NOT) 54,28,54                                                 CM2 234 
54    DO 59 J=2,NV                                                      CM2 235 
      IF (NT(J)) 55,59,55                                               CM2 236 
55    KK=NT(J)                                                          CM2 237 
      DO 58 I=1,KK,2                                                    CM2 238 
      LL=NOTIES(I,J)                                                    CM2 239 
      MM=NOTIES(I+1,J)                                                  CM2 240 
      NN=MM                                                             CM2 241 
      A=0.                                                              CM2 242 
      DO 56 K=1,LL                                                      CM2 243 
      JJ=INDI(NN,J)                                                     CM2 244 
      A=A+YX(JJ,J)                                                      CM2 245 
56    NN=NN+1                                                           CM2 246 
      NN=MM                                                             CM2 247 
      A=A/FLOAT(LL)                                                     CM2 248 
      DO 57 L=1,LL                                                      CM2 249 
      JJ=INDI(NN,J)                                                     CM2 250 
      YX(JJ,J)=A                                                        CM2 251 
57    NN=NN+1                                                           CM2 252 
58    CONTINUE                                                          CM2 253 
59    CONTINUE                                                          CM2 254 
      GO TO 28                                                          CM2 255 
C     PRINT OUT RESULTS                                                 CM2 256 
60    WRITE (JTAPE,76) I,J                                              CM2 257 
61    WRITE (JTAPE,77)                                                  CM2 258 
      DO 62 I=1,NS                                                      CM2 259 
62    WRITE (JTAPE,78) I,(YX(I,J),J=1,NV)                               CM2 260 
      WRITE (JTAPE,79) CAL,ITER                                         CM2 261 
C     CONVERT MONOTONE SCORES TO USM                                    CM2 262 
      DO 64 J=1,NV                                                      CM2 263 
      A=0.                                                              CM2 264 
      B=0.                                                              CM2 265 
      DO 63 I=1,NS                                                      CM2 266 
      A=A+YX(I,J)                                                       CM2 267 
63    B=B+YX(I,J)**2                                                    CM2 268 
      A=A/FN                                                            CM2 269 
      B=SQRT(B/FN-A**2)                                                 CM2 270 
      DO 64 K=1,NS                                                      CM2 271 
64    YX(K,J)=(YX(K,J)-A)/B                                             CM2 272 
C     CORRELATE VARIOUS MEASURES                                        CM2 273 
      DO 66 J=2,NV                                                      CM2 274 
      WX(J,1)=0.                                                        CM2 275 
      DO 65 I=1,NS                                                      CM2 276 
65    WX(J,1)=WX(J,1)+YX(I,1)*YX(I,J)                                   CM2 277 
66    WX(J,1)=WX(J,1)/FN                                                CM2 278 
      WRITE (JTAPE,80) (WX(J,1),J=2,NV)                                 CM2 279 
      PHI=0.                                                            CM2 280 
      CAL=0.                                                            CM2 281 
      A=0.                                                              CM2 282 
      DO 67 I=1,NS                                                      CM2 283 
67    PHI=PHI+W(I)*YX(I,1)                                              CM2 284 
      PHI=PHI/FN                                                        CM2 285 
      WRITE (JTAPE,81) PHI                                              CM2 286 
      IF (ICARDS) 68,1,68                                               CM2 287 
68    DO 69 I=1,NS                                                      CM2 288 
69    PUNCH 82, I,(YX(I,J),J=2,NV),YX(I,1)                              CM2 289 
      GO TO 1                                                           CM2 290 
C     *** FORMAT STATEMENTS                                             CM2 291 
C                                                                       CM2 292 
70    FORMAT (72H                                                       CM2 293 
     1                 )                                                CM2 294 
71    FORMAT (4I4,3F4.4)                                                CM2 295 
72    FORMAT (18A4)                                                     CM2 296 
73    FORMAT (6H0MEANS/(10F13.3))                                       CM2 297 
74    FORMAT (20H0STANDARD DEVIATIONS/(10F13.3))                        CM2 298 
75    FORMAT (31H0CORRELATIONS BETWEEN Y AND X'S/13X9F13.4/(10F13.4))   CM2 299 
76    FORMAT (28H0OUTLIER FOUND FOR SUBJECT =,I4,15H AND VARIABLE =,I3,1CM2 300 
     1H.,23H  ITERATIONS CONCLUDED.)                                    CM2 301 
77    FORMAT (42H1GUTTMAN-LINGOES CONJOINT MEASUREMENT - II/36H0MONOTONICM2 302 
     1CALLY TRANSFORMED Y AND X'S/8H0SUBJECT,8X6HWEIGHT,46X21HINDEPENDENCM2 303 
     2T VARIABLES/1H ,131(1H-))                                         CM2 304 
78    FORMAT (I6,E20.6,6E17.6/(26X6E17.6))                              CM2 305 
79    FORMAT (28H0COEFFICIENT OF ALIENATION =,E13.6,5H FOR ,I5,12H ITERACM2 306 
     1TIONS.)                                                           CM2 307 
80    FORMAT (40H1CORRELATIONS BETWEEN MONOTONE Y AND X'S/13X9F13.4/(10FCM2 308 
     113.4))                                                            CM2 309 
81    FORMAT (10H0R(Y,Y*) =,F8.4)                                       CM2 310 
82    FORMAT (I4,9F7.4/(10F7.4))                                        CM2 311 
      END                                                               CM2 312-
1TEST ON THE FIRST AND SECOND PRINCIPAL COMPONENTS.                             
   7   3                                                                        
(3F4.3)                                                                         
9000 529 509                                                                    
8000 409  69                                                                    
7000 230-320                                                                    
6000   0-516                                                                    
5000-230-320                                                                    
4000-409  69                                                                    
3000-529 509                                                                    
12 PERFECTLY NEGATIVELY CORRELATED VARIABLES.                                   
   5   3                                                                        
(3F1.0)                                                                         
451                                                                             
142                                                                             
533                                                                             
224                                                                             
315                                                                             
1X=Y, X=Y**2, AND X=Y**3.                                                       
   5   4                7000                                                    
(4F3.0)                                                                         
  0  0  0  0                                                                    
  1  1  1  1                                                                    
  2  2  4  8                                                                    
  3  3  9 27                                                                    
 -2 -2  4 -8                                                                    
1X1=Y**2,X2=2Y+5,X3=Y+X1,X4=X1+X2.                                              
  10   5                                                                        
(5F3.0)                                                                         
  1  1  7  2  8                                                                 
 -1  1  6  0  7                                                                 
  2  4  9  6 13                                                                 
 -2  4  1  2  5                                                                 
  3  9 11 12 20                                                                 
 -3  9 -1  6  8                                                                 
  4 16 13 20 29                                                                 
 -4 16 -3 12 13                                                                 
  9 81 23 90104                                                                 
 -9 81-13 72 68                                                                 
1EXAMPLE WITH TIED DATA                                                         
  15   4                                                                        
(4F2.0)                                                                         
 1 1 5 1                                                                        
 1 2 4 4                                                                        
 1 3 3 5                                                                        
 1 4 2 3                                                                        
 1 5 1 2                                                                        
 210 6 9                                                                        
 2 9 7 6                                                                        
 2 8 810                                                                        
 2 7 9 7                                                                        
 2 610 8                                                                        
 3 6 7 8                                                                        
 3111213                                                                        
 3141516                                                                        
 3161514                                                                        
 3131211                                                                        
