-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrks.f
executable file
·5951 lines (5948 loc) · 180 KB
/
wrks.f
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*SCC
SUBROUTINE SCC
C
C ** NBS OMNITAB 1980 VERSION 6.01 1/ 1/81. SCC V 7.00 2/22/90. **
C
C ==================================================================
C
C *** GENERAL COMMENTS ***
C
C THIS PROGRAM UNIT HANDLES INSTRUCTIONS OF THE FORM ...
C XXXXXX OF COLS (C), (C), ..., (C) PUT IN COLS (C), (C), ..., (C)
C
C FOR L2=11, INSTRUCTION IS - AVERAGE
C FOR L2=12, INSTRUCTION IS - STDDEV
C FOR L2=13, INSTRUCTION IS - MEDIAN
C FOR L2=14, INSTRUCTION IS - RANGE
C FOR L2=15, INSTRUCTION IS - PERCENTAGES
C FOR L2=16, INSTRUCTION IS - PROPORTIONS
C
C WRITTEN BY -
C DAVID HOGBEN,
C STATISTICAL ENGINEERING DIVISION,
C CENTER FOR COMPUTING AND APPLIED MATHEMATICS,
C A337 ADMINISTRATION BUILDING,
C NATIONAL INSTITUTE OF STANDARDS AND TECHNOLOGY,
C GAITHERSBURG, MD 20899
C TELEPHONE 301-975-2845
C ORIGINAL VERSION - FEBRUARY, 1977.
C CURRENT VERSION - FEBRUARY, 1990.
C
C ==================================================================
C
C *** SPECIFICATION STATEMENTS ***
C
COMMON /ARGMTS/ ARGS(100), IARGS(100), KIND(100), NARGS
COMMON /ICONST/ IFIVE, IFOUR, IHRD, IONE, ITEN, ITHRE, ITWO, IZERO
COMMON /INSTRN/ L1, L2, NCOL, NERROR, NRMAX, NROW
COMMON /RCONST/ RFIVE, RFOR, RHALF, RONE, RTEN, RTHRE, RTWO, RZERO
C
INCLUDE 'WRKSCR.H'
C
REAL AMAX, AMIN, AN, AVEX, CONST, SS, SUM, X, XCODE
REAL FDIV, FSQRT
C
DOUBLE PRECISION SUMX, SQRTCT
C
C ==================================================================
C
C ERROR CHECKING.
C
IF (NRMAX.GT.IZERO) GO TO 10
CALL ERROR ( 9)
RETURN
C
C ..................................................................
C
10 K = MOD (NARGS,ITWO)
IF (K.EQ.IZERO .AND. NARGS.GE.ITWO) GO TO 20
CALL ERROR (10)
RETURN
C
C ..................................................................
C
20 CALL CHKCOL
IF (NERROR.NE.IZERO) RETURN
C
C ==================================================================
C
L = IDIV (NARGS,ITWO,IND)
AN = FLOAT (NRMAX)
X = RZERO
DO 230 I=1,L
M = IARGS(I)
K = I + L
N = IARGS(K)
K = L2 - ITEN
GO TO (30,50,90,150,30,30), K
C
C AVERAGE.
C
30 CALL SUMMAL (RC(M), IZERO,SUM)
DO 40 J=1,NRMAX
CALL SUMMAL (RC(M),-IONE,SUM)
M = M + IONE
40 CONTINUE
C
CALL SUMMAL (RC(M), IONE,SUM)
IF (L2.EQ.15) GO TO 170
IF (L2.EQ.16) GO TO 180
X = FDIV (SUM,AN,IND)
GO TO 190
C
C STANDARD DEVIATION.
C
50 IF (NRMAX.GT.IONE) GO TO 60
X = RZERO
GO TO 190
C
60 CALL CODEXX (RC(M),NRMAX,SUMX,AVEX,XCODE,SQRTCT,A(1),K)
DO 70 J=1,NRMAX
A(J) = A(J)**2
70 CONTINUE
C
CALL SUMMAL (A(1), IZERO,SUM)
DO 80 J=1,NRMAX
CALL SUMMAL (A(J),-IONE,SUM)
80 CONTINUE
CALL SUMMAL (A(1), IONE,SUM)
SS = DBLE(SUM) - SQRTCT**2
X = FSQRT ( FDIV (SS,AN-RONE,IND) )
GO TO 190
C
C RANGE.
C
90 IF (NRMAX.GT.IONE) GO TO 100
X = RZERO
GO TO 190
C
100 AMIN = RC(M)
AMAX = RC(M)
DO 140 J=2,NRMAX
M = M + IONE
IF (RC(M)-AMIN) 110,120,120
110 AMIN = RC(M)
GO TO 140
120 IF (RC(M)-AMAX) 140,140,130
130 AMAX = RC(M)
140 CONTINUE
X = AMAX - AMIN
GO TO 190
C
C MEDIAN.
C
150 DO 160 J=1,NRMAX
A(J) = RC(M)
M = M + IONE
160 CONTINUE
CALL SORT (A(1),RC(N),NRMAX,IONE)
K1 = MOD (NRMAX,ITWO)
K2 = IDIV (NRMAX,ITWO,IND)
IF (K1.EQ.IZERO) X = FDIV (A(K2)+A(K2+1),RTWO,IND)
IF (K1.EQ.IONE) X = A(K2+1)
GO TO 190
C
C PERCENTAGES.
C
170 CONST = FLOAT (IHRD)
GO TO 210
C
C PROPORTIONS.
C
180 CONST = RONE
GO TO 210
C
C
190 DO 200 J=1,NRMAX
RC(N) = X
N = N + IONE
200 CONTINUE
GO TO 230
C
C
210 M = M - NRMAX
DO 220 J=1,NRMAX
RC(N) = CONST * FDIV (RC(M),SUM,IND)
M = M + IONE
N = N + IONE
220 CONTINUE
230 CONTINUE
RETURN
C
C ==================================================================
C
END
*SCNARG
SUBROUTINE SCNARG (LNAME,JA,MATSWT,IMAT,INDX)
C
C ** NBS OMNITAB 1980 VERSION 6.01 1/ 1/81. SCNARG V 7.00 4/21/92 **
C
C ==================================================================
C
C *** GENERAL COMMENTS ***
C
C THIS PROCEDURE SCANS THE INPUT CARD FOR ARGUMENTS.
C IF ILABEL IS NOT ZERO, THEN CARD IS ALSO SCANNED FOR VARIABLES.
C
C INPUT.
C
C LNAME NUMBER OF WORDS IN COMMAND.
C
C OUTPUT.
C
C JA AMOUNT OF INFORMATION STORED IN ARGTAB.
C INDX = 0, NO ERRORS ENCOUNTERD.
C = 1, ERRORS FOUND.
C
C REVISED BY -
C SALLY T. PEAVY,
C STATISTICAL ENGINEERING DIVISION,
C COMPUTING AND APPLIED MATHEMATICS LABORATORY,
C A337 ADMINISTRATION BUILDING,
C NATIONAL INSTITUTE OF STANDARDS AND TECHNOLOGY,
C GAITHERSBURG, MD 20899
C TELEPHONE 301-975-2845
C ORIGINAL VERSION - MAY, 1978.
C CURRENT VERSION - APRIL, 1992.
C
C ==================================================================
C
C *** SPECIFICATION STATEMENTS ***
C
DIMENSION ICARD(100)
C
COMMON /ABCDEF/ LA(74)
COMMON /ARGMTS/ ARGS(100), IARGS(100), KIND(100), NARGS
COMMON /ICONST/ IFIVE, IFOUR, IHRD, IONE, ITEN, ITHRE, ITWO, IZERO
COMMON /INSTRN/ L1, L2, NCOL, NERROR, NRMAX, NROW
COMMON /IOUNIT/ INUNIT, IPUNCH, ISCRT, KBDOUT, LTAPE, MPRNT, NPRNT
COMMON /IOUNIT/ LPTAPE
COMMON /RCONST/ RFIVE, RFOR, RHALF, RONE, RTEN, RTHRE, RTWO, RZERO
COMMON /REPMOD/ ARGTAB(100), COM(2000), INDEX(6,8), LEVEL, NSTMTH
COMMON /SCNCHR/ NEWCRD(80)
COMMON /SCNCRD/ ARG, ARG2, KARG, KRDPOS, MODE
COMMON /SCNLCD/ LENCRD, LKARD, KARD(83), KRDEND
COMMON /STRINS/ IOVFL, IRMV, LCOM, NCOM, NSTMT, NSTMTX
COMMON /SWITCH/ IHCNT, ILABEL, ISBFT, KRDKNT, NCRT, NDEMD, NLOCRM
COMMON /VECDIM/ RSUM(172), VWXYZ(8), NAME(8)
C
INCLUDE 'WRKSCR.H'
C
C ==================================================================
C
C *** TYPE STATEMENTS ***
C
REAL RELINC, T
REAL SPCA
C
CHARACTER KA*1
CHARACTER LA*1
CHARACTER NEWCRD*1
C ==================================================================
C
C *** DATA INITIALIZATION STATEMENTS ***
C
DATA RELINC / 8192.0 /
C
DATA SPCA / 8208.0 /
C
DATA ICA / 44 /
DATA ICB / 46 /
DATA ICC / 35 /
DATA ICD / 100000 /
DATA ICE / 40 /
DATA ICF / 100 /
C
C =================================================================
C
JA = JA + IONE
ISWT = IONE
KRDPST = KRDPOS
MS = KRDPOS
MZA = KRDPOS
T = RZERO
KLABEL = IZERO
DO 240 IPOS=KRDPST,LKARD
K = KARD(KRDPOS)
IF (K.NE.ICA .OR. ILABEL.LE.IZERO) GO TO 50
C
C ILABEL IS NOT ZERO. CHECK DISCRIPTORS FOR
C VARIABLE ARGUMENTS.
C
C IF KLABEL = 0, DEFINE NUMERIC VALUE OF NEWCRD INTO ICARD
C
IF (KLABEL .EQ. IZERO) THEN
KLABEL = IONE
DO 6 KL =1, KRDEND
KA = NEWCRD(KL)
DO 4 KB = 1,74
IF (KA .EQ. LA(KB)) ICARD(KL+2) = KB - IONE
4 CONTINUE
6 CONTINUE
ENDIF
KARG = IZERO
C
CALL BLANK
C
10 IF (LNAME.LE.IZERO .OR. LNAME.GT.IFOUR) GO TO 40
IF (MODE.EQ.ITWO .AND. NAME(1).EQ.IZERO) GO TO 40
IF (L1.EQ.16 .AND. L2.GT.ITWO. AND. L2.LE.IFIVE) GO TO 40
MZZ = KRDPOS
C
CALL NONBLA (MZZ,K)
C
MZA = KRDPOS
IF (K.EQ.ICB) GO TO 150
IF (K.GT.ICC) GO TO 40
C
CALL ZLCVAR (ICARD(KRDPOS),IND,IA,LOC)
C
IF (IND.GT.IZERO) GO TO 40
IZSTP = IDIV (IA,ICD,IND)
IA = MOD (IA,ICD)
IF (IZSTP.GT.IZERO) GO TO 20
ARG = IA
ISWT = IFIVE
IF (KARG.GT.IZERO) GO TO 30
IF (KARG.LE.IZERO) GO TO 200
20 IF (KARG.GT.IZERO) GO TO 90
ARG = MOD (IZSTP,NROW)
ISWT = ITWO
GO TO 200
30 IAB = MOD (LOC,ICF)
KRDPOS = MZA + IAB
ISWT = IONE
IAB = IZERO
IF (KARG.EQ.IZERO) GO TO 230
MZZ = KRDPOS
C
CALL NONBLA (MZZ,K)
C
IF (K.NE.ICE) GO TO 90
ARG2 = ARG
ARG = T
KARG = KARG - ITHRE
KRDPOS = KRDPOS + IONE
K = KARD(KRDPOS)
IF (KARG.NE.IFIVE) GO TO 110
IF (K.NE.ICE) GO TO 90
KRDPOS = KRDPOS + IONE
K = KARD(KRDPOS)
GO TO 110
40 IF (KARG.NE.IZERO) GO TO 90
50 IF (K.GE.ITEN .AND. K.EQ.ICE) GO TO 70
IF (K.GE.ITEN .AND. K.GT.ICE) GO TO 150
IF (K.GE.ITEN .AND. K.LT.ICE) GO TO 190
C
C NUMBER FOUND, CONVERT ARGUMENT. IF KARG RETURNED = 0, NUMBER IS
C INTEGER,IF KARG = 1, NUMBER IS FLOATING POINT, IF KARG = -1, ERROR
C
CALL AARGS (KARD)
C
MATSWT = IZERO
IF (KARG.EQ.IZERO) GO TO 200
IF (KARG.LT.IZERO) GO TO 250
60 ARGTAB(JA) = RZERO
JA = JA + IONE
GO TO 210
C
C ASTERISK FOUND, CONVERT
C
C IF BRACKETED BY SINGLE ASTERISKS, QUANTITY IS TO BE USED AS A
C FLOATING POINT ARGUMENT.IF BRACKETED BY DOUBLE ASTERISKS, QUANTITY
C IS TO BE TRUNCATED AND USED AS AN INTEGER ARGUMENT.
C
C IF COMMAND IS EVALUATE BY-PASS CHECK ON ASTERISKS.
C
70 KARG = IONE
KRDPOS = KRDPOS + IONE
IF (KARD(KRDPOS).NE.ICE) GO TO 80
KARG = IZERO
KRDPOS = KRDPOS + IONE
80 MS = KRDPOS
C
CALL ASTER
C
C THE TERMINAL ASTERISK(S) HAVE BEEN CHECKED TO BE THE SAME AS THE
C INTITAL SET (IF NO ERROR) AND M IS POINTING AT THE FIRST CHARACTER
C AFTER THE LAST ASTERISK.
C
C KARG RETURNED AS 1 = ERROR FOUND
C 2 = FLOATING POINT CONSTANT, I.E. *PI*
C 3 = INTEGER NAMED VARIABLE, I.E. **NRMAX**
C 4 = FL. PT. NAMED VARIABLE, I.E. *NRMAX*
C 5 = INTEGER ROW-COLUMN, I.E. **3,40**
C 6 = FL. PT. ROW-COLUMN, I.E. *1,2*
C 7 = STRING OF ASTERISKS I.E. ***
C 8 = INTEGER ROW-COLUMN, I.E. **3,VARIABLE**
C 9 = FL. PT. ROW-COLUMN, I.E. *1,VARIABLE*
C
C A STRING OF THREE OR MORE ASTERISKS IMPLIES -THRU-
C EXAMPLE..
C ERASE 1 2 3 4 12 13 14 15 16 20
C IS EQUIVALENT TO
C ERASE 1 *** 4, 12 *** 16, 20
C
C PRINT 1 20 19 18 17 16 15 14
C IS EQUIVALENT TO
C PRINT 1, 20 *** 14
C
GO TO (90,60,100,100,110,110,120,140,140), KARG
C
90 KRDPOS = MS
KARG = IZERO
GO TO 240
C
100 ARGTAB(JA) = -RTWO*ARG - FLOAT (KARG-ITHRE)
GO TO 220
C
110 ARGTAB(JA) = -(ARG+SPCA)
ARG2 = ARG2 + RELINC
IF (KARG.EQ.6) ARG2 = -ARG2
JA = JA + IONE
ARGTAB(JA) = ARG2
GO TO 220
C
120 IF (JA.GT.IZERO) GO TO 130
CALL ERROR (211)
GO TO 240
C
130 ARGTAB(JA) = -RONE
GO TO 230
C
C ARGTAB SETUP
C
C IF ENTRY .GT. 0, IT IS AN INTEGER CONSTANT (I.E., COLUMN NUMBER)
C TO WHICH A BIAS OF 8192 HAS BEEN ADDED. THIS IS TO SAY THAT A
C NEGATIVE INTEGER ARGUMENT MAY NOT BE EXPLICITLY GIVEN OR MODIFIED
C TO BE LESS THAT -8191.
C
C IF ENTRY .EQ.0, THE NEXT ENTRY IS A FLOATING POINT CONSTANT.
C
C IF ENTRY .LT. 0, ARGUMENT IS A VARIABLE. SET SIGN POSITIVE AND..
C
C IF ENTRY .LT. 16, IT IS A NAMED VARIABLE REFERENCE NUMBER
C
C 2,3 NRMAX 6,7 V 10,11 X
C 8,9 W 12,13 Y
C 14,15 Z
C
C V,W,X,Y,Z, ARE FOR PROGRAMMING CONVENIENCE ONLY AND DO NOT
C AFFECT THE OPERATION OF OMNITAB.
C
C IF ENTRY IS EVEN, CURRENT VALUE TO BE TRUNCATED AND USED
C AS AN INTEGER ARGUMENT.
C IF ENTRY IS ODD. THE CURRENT VALUE IS TO BE USED AS A
C FLOATING POINT ARGUMENT.
C
C IF ENTRY .GT. 16, IT IS A WORKSHEET REFERENCE (ROW,COLUMN) TO
C WHICH A BIAS OF 8208.0 HAS BEEN ADDED.
C ENTRY - 8208 = ROW NUMBER
C ABS(NEXT ENTRY) = COLUMN NUMBER TO WHICH A BIAS OF 8192.
C HAS BEEN ADDED.
C
C IF NEXT ENTRY IS NEGATIVE, WORKSHEET CONTENTS ARE TO BE
C USED AS A FLOATING POINT CONSTANT. IF +, WORKSHEET VALUE
C TO BE TRUNCATED AND USED AS AN INTEGER ARGUMENT.
C
140 T = ARG
GO TO 10
C
150 IF (K.NE.ICB) GO TO 190
INDX = IZERO
RETURN
C
C ..................................................................
C
160 JA = JA + IONE
ARG = IDIV (IZSTP,NROW,IND) + IONE
ISWT = ITHRE
GO TO 200
C
170 JA = JA + IONE
ARG = IA
ISWT = IFOUR
GO TO 200
C
180 JA = JA + IONE
ARG = IDIV (LOC,IHRD,IND)
ISWT = IFIVE
MATSWT = IONE
IMAT = IMAT + IONE
GO TO 200
C
190 KRDPOS = KRDPOS + IONE
GO TO 240
C
C ARGUMENT IS AN INTEGER. ADD A BIAS OF 8192 THEN CHECK THAT IT IS
C .GT. 0
C
200 ARG = ARG + RELINC
IF (ARG.GT.RZERO) GO TO 210
CALL ERROR (18)
GO TO 250
C
210 ARGTAB(JA) = ARG
220 NARGS = NARGS + IONE
GO TO (230,160,170,180,30), ISWT
230 JA = JA + IONE
240 CONTINUE
C
250 INDX = IONE
RETURN
C
C =================================================================
C
END
*SCREEN
SUBROUTINE SCREEN (RR,KX,NR,NDEF,IBIT,MBST,INTCPT)
C
C ** NBS OMNITAB 1980 VERSION 6.01 1/ 1/81. SCREEN V 7.00 4/21/92. **
C
C ==================================================================
C
C *** GENERAL COMMENTS ***
C
C **************************************************************** *
C *
C REGRESSIONS BY LEAPS AND BOUNDS *
C A PROGRAM FOR FINDING THE BEST SUBSET REGRESSIONS *
C G.M.FURNIVAL AND R.W.WILSON *
C YALE UNIVERSITY AND U.S. FOREST SERVICE *
C VERSION 11/11/74 *
C *
C CALL SCREEN(RR,KX,NR,NDEF,IBIT,MBST) *
C *
C RR = UPPER TRIANGULAR PORTION OF (KX+1)*(KX+1) CORRELATION OR *
C PRODUCT MATRIX. VARIABLE KX+1 IS THE DEPENDENT VARIABLE. *
C KX = NUMBER OF INDEPENDENT VARIABLES (3.LE.KX.LE.28) *
C NR = DIMENSION OF RR (NR.GT.KX) *
C NDEF = DEGREES OF FREEDOM FOR RR (NDEF.GT.KX) *
C IBIT = SELECTION CRITERION CODE (1=R**2,2=ADJUSTED R**2,3=CP) *
C MBST = NUMBER OF BEST REGRESSIONS DESIRED (1.LE.MBST.LE.10) *
C *
C MBST BEST REGRESSIONS FOR EACH SIZE SUBSET WHEN IBIT.EQ.1 *
C MBST BEST REGRESSIONS IN TOTAL WHEN IBIT.GT.1 *
C *
C **************************************************************** *
C
C ARRAY STORAGE REQUIRED FOR K=KX INDPENDENT VARIABLES AND M = K+1.
C 2*NL FOR XI AND XN, WHERE NL = M(M+1)(M+2)/6
C 4M**2 FOR ILI, ILM, MD AND NC
C 2*(11M) FOR CL AND RM
C 12M FOR CI, CN, CO, ID, IPI, IPN, NI, NN, TOLL, YI, YN AND ZC
C
C TOTAL STORAGE EQUALS 2M(M+1)(M+2)/6 + 4M**2 +22M + 12M
C = (M**3 + 15*M**2 + 104*M)/3
C
C *** ARRAY STORAGE EQUIVALENCE TO A(.) ***
C
C ARRAY SIZE START
C
C XI NL 1
C XN NL NL+1
C .............................................
C ILI M**2 2*NL+ 1
C ILN M**2 2*NL+ M**2+1
C MD M**2 2*NL+2*M**2+1
C NC M**2 2*NL+3*M**2+1
C .............................................
C CL 11*M 2*NL+4*M**2+ 1
C RM 11*M 2*NL+4*M**2+11*M+1
C .............................................
C CI M 2*NL+4*M**2+22*M+1
C CN M 2*NL+4*M**2+23*M+1
C CO M 2*NL+4*M**2+24*M+1
C ID M 2*NL+4*M**2+25*M+1
C IPI M 2*NL+4*M**2+26*M+1
C IPN M 2*NL+4*M**2+27*M+1
C NI M 2*NL+4*M**2+28*M+1
C NN M 2*NL+4*M**2+29*M+1
C TOLL M 2*NL+4*M**2+30*M+1
C YI M 2*NL+4*M**2+31*M+1
C YN M 2*NL+4*M**2+32*M+1
C ZC M 2*NL+4*M**2+33*M+1
C .............................................
C
C ADAPTED TO OMNITAB COMPUTING SYSTEM BY -
C DAVID HOGBEN,
C STATISTICAL ENGINEERING DIVISION,
C COMPUTING AND APPLIED MATHEMATICS LABORATORY,
C A337 ADMINISTRATION BUILDING,
C NATIONAL INSTITUTE OF STANDARDS AND TECHNOLOGY,
C GAITHERSBURG, MD 20899
C TELEPHONE 301-921-3651
C ORIGINAL VERSION - FEBRUARY, 1977.
C CURRENT VERSION - APRIL, 1992.
C
C ==================================================================
C
C *** SPECIFICATION STATEMENTS ***
C
DIMENSION ID(29), IPI(29), IPN(29), NI(29), NN(29)
DIMENSION ILI(845), ILN(845), MD(845), NC(845)
C
COMMON /DCONST/ DEHT, DFOR, DHALF, DONE, DSIX, DTHRE, DTWO, DZERO
COMMON /ICONST/ IFIVE, IFOUR, IHRD, IONE, ITEN, ITHRE, ITWO, IZERO
COMMON /INSTRN/ L1, L2, NCOL, NERROR, NRMAX, NROW
COMMON /RCONST/ RFIVE, RFOR, RHALF, RONE, RTEN, RTHRE, RTWO, RZERO
COMMON /RMCONS/ RALOG, RER, REXP, RMIFY, RMXINT, RPIFY, RSD, RTRG
COMMON /SWITCH/ IHCNT, ILABEL, ISBFT, KRDKNT, NCRT, NDEMD, NLOCRM
COMMON /TOPRNT/ IPRINT, ISIGD, LENGTH, LWC, LWIDE, NCW
C
INCLUDE 'WRKSCR.H'
C
C ==================================================================
C
C *** TYPE STATEMENTS ***
C
REAL RR(29,29)
REAL BOUND, CAB, RS, R2
REAL SIG, SS, TEMP, TOL, TWO
REAL FDIV
REAL SPCA, SPCB
C
C ..................................................................
C
DOUBLE PRECISION DEHT, DFOR, DHALF, DONE, DSIX, DTHRE, DTWO, DZERO
C
C ==================================================================
C
C *** DATA INITIALIZATION STATEMENTS ***
C
DATA KO, NV / 10, 11 /
C
DATA SPCA / 100.0 /
DATA SPCB / 10000.0 /
C
C ==================================================================
C
C 10=KO=NV-1 NL=(KX+1)*(KX+2)*(KX+3)/6 ND-1=NR-1
C NX=(KX+1)*(KX+2)/2
C
C SET UP SIZE OF KZ, ND, NL AND NX.
C
KZ = KX + IONE
ND = KZ
NL = IDIV (ND * (ND + IONE) * (ND + ITWO),6,IND)
NX = IDIV (ND * (ND + IONE),ITWO,IND)
C
C TEST INPUT.
C
KZSIZE = ITWO * NL + IFOUR * ND ** 2 + 34 * ND
IF (KZSIZE.GT.NS) CALL ERROR (23)
IF (NERROR.NE.IZERO) RETURN
C
C ..................................................................
C
IF (KX.GE.ITHRE .AND. KX.LT.ND .AND. NDEF.GT.KX .AND.
1 MBST.GT.IZERO .AND. MBST.LE.KO .AND. KO.LE.NV .AND. NR.GT.KX
2 .AND. IBIT.GE.IONE .AND. IBIT.LE.ITHRE) GO TO 10
CALL ERROR (3)
RETURN
C
C ..................................................................
C
10 SS = FDIV (RR(KZ,KZ),SPCA,IND)
IF (IBIT.EQ.ITWO) SS = FDIV (SS,FLOAT(NDEF),IND)
IF (SS.GT.RZERO) GO TO 30
20 CALL ERROR (22)
RETURN
C
C ..................................................................
C
C INITIALIZE.
C
30 LSUBXI = IONE
LSUBXC = IONE
LSUBXN = NL + IONE
LSUBLI = ITWO * NL + IONE
LSUBLN = LSUBLI + KZ ** 2
LSUBMD = LSUBLN + KZ ** 2
LSUBNC = LSUBMD + KZ ** 2
LSUBCL = LSUBNC + KZ ** 2
LSUBRM = LSUBCL + 11 * KZ
LSUBCI = LSUBRM + 11 * KZ
LSUBCN = LSUBCI + KZ
LSUBCO = LSUBCN + KZ
LSUBID = LSUBCO + KZ
LSUBPI = LSUBID + KZ
LSUBPN = LSUBPI + KZ
LSUBNI = LSUBPN + KZ
LSUBNN = LSUBNI + KZ
LSUBTL = LSUBNN + KZ
LSUBYI = LSUBTL + KZ
LSUBYN = LSUBYI + KZ
LSUBZC = LSUBYN + KZ
A(LSUBCN) = RZERO
A(LSUBCI) = RZERO
TOL = FDIV (RER,SPCB,IND)
TWO = RTWO * RR(KZ,KZ) * FLOAT(NDEF)
LOW = KO - MBST + IONE
LISUBL = IONE
LNSUBL = IONE
MDSUBL = IONE
NCSUBL = IONE
IDSUBL = IONE
NPSUBL = IONE
IPSUBL = IONE
NISUBL = IONE
NNSUBL = IONE
ISUBLI = LISUBL
ISUBNC = NCSUBL
ISUBCL = LSUBCL
ISUBRM = LSUBRM
ISUBCO = LSUBCO
KSUBRM = LSUBRM + KO
ISUBID = IDSUBL
ISUBPN = NPSUBL
ISUBTL = LSUBTL
NTLINE = 60
IF (NCRT.NE.IZERO) NTLINE = LENGTH + ITHRE
DO 50 L=1,KZ
ID(ISUBID) = IDIV ((KZ-IONE)*KZ*(KZ+IONE)-(KZ-L)*(KZ-L+IONE)*
1 (KZ-L+ITWO),6,IND)
IPN(ISUBPN) = IONE
ILI(ISUBLI) = L
A(KSUBRM) = -TWO
KSUBRM = KSUBRM + 11
A(ISUBCO) = DTWO**(KX-L)
NC(ISUBNC) = L
A(ISUBTL) = TOL * RR(L,L)
IF (A(ISUBTL).LE.RZERO) GO TO 20
JSUBCL = ISUBCL
JSUBRM = ISUBRM
DO 40 M=1,KO
A(JSUBCL) = RZERO
A(JSUBRM) = TWO
JSUBCL = JSUBCL + IONE
JSUBRM = JSUBRM + IONE
40 CONTINUE
ISUBCL = ISUBCL + 11
ISUBRM = ISUBRM + 11
ISUBCO = ISUBCO + IONE
ISUBLI = ISUBLI + KZ
ISUBNC = ISUBNC + KZ
ISUBID = ISUBID + IONE
ISUBPN = ISUBPN + IONE
ISUBTL = ISUBTL + IONE
50 CONTINUE
C
C STORE MATRICES AS VECTORS.
C
LS = IZERO
ISUBXC = LSUBXC - IONE
ISUBXN = LSUBXN
ISUBMD = MDSUBL
MSUBMD = MDSUBL - IONE
DO 70 L=1,KZ
KSUBMD = ISUBMD
JSUBMD = MSUBMD + KZ * (L - IONE) + L
DO 60 M=L,KZ
LS = LS + IONE
ISUBXC = ISUBXC + IONE
MD(KSUBMD) = LS
MD(JSUBMD) = LS
A(ISUBXC) = RR(L,M)
A(ISUBXN) = A(ISUBXC)
RR(M,L) = RR(L,M)
ISUBXN = ISUBXN + IONE
KSUBMD = KSUBMD + KZ
JSUBMD = JSUBMD + IONE
60 CONTINUE
ISUBMD = ISUBMD + IONE + KZ
70 CONTINUE
C
C INVERT MATRIX STEPWISE.
C
ISUBMD = MDSUBL + KZ ** 2 - IONE
ISUB2 = MD(ISUBMD) + LSUBXC - IONE
NSUBLI = LISUBL
NSUBLN = LNSUBL
NSUBMD = MDSUBL + KZ * (KZ - IONE) - IONE
ISUBRM = LSUBRM - IONE + KO
MSUBRM = LSUBRM
ISUBCO = LSUBCO - IONE
DO 90 N=1,KX
J = IZERO
N1 = N
ISUBLI = NSUBLI
DO 80 LA=N,KX
L = ILI(ISUBLI)
ISUBLI = ISUBLI + KZ
ISUBMD = MDSUBL + KZ * (L -IONE) - IONE
MSUBMD = NSUBMD + L
ISUBMD = ISUBMD + L
ISUBTL = LSUBTL + L - IONE
ISUB1 = MD(ISUBMD) + LSUBXC - IONE
IF (A(ISUB1).LT.A(ISUBTL)) GO TO 80
ISUB3 = MD(MSUBMD) + LSUBXC - IONE
RS = A(ISUB2) - FDIV (A(ISUB3)*A(ISUB3),A(ISUB1),IND)
IF (RS.LT.A(ISUBRM)) J = LA
MSUBCO = ISUBCO + L
IF (RS.LT.A(MSUBRM)) CALL CPSTRE (RS,A(LSUBCI)+A(MSUBCO),
1 KO,A(LSUBCL),A(LSUBRM),N1,NV,ND)
80 CONTINUE
IF (J.EQ.IZERO) GO TO 100
JSUBLI = LISUBL + KZ * (J -IONE)
M = ILI(JSUBLI)
ILI(JSUBLI) = ILI(NSUBLI)
ILI(NSUBLI) = M
ILN(NSUBLN) = M
MSUBCO = ISUBCO + M
A(LSUBCI) = A(LSUBCI) + A(MSUBCO)
NSUBLI = NSUBLI + KZ
NSUBLN = NSUBLN + KZ
ISUBRM = ISUBRM + 11
MSUBRM = MSUBRM + 11
CALL PIVOT (A(LSUBXC),KZ,M,MD(MDSUBL),ND,NX)
90 CONTINUE
C
N = KZ
100 K = N - IONE
KP = KZ * K + LISUBL
KXSUBL = KZ * (KX - IONE) + LISUBL
IF (K.NE.KX) WRITE (IPRINT,330) (ILI(I),I=KP,KXSUBL,KZ)
IF (K.LT.ITHRE) RETURN
KM = K - IONE
C
C INTCPT - IONE = ADJUSTMENT FOR USING WITH NO CONSTANT TERM.
C
SIG = FDIV (RTWO*A(ISUBXC),FLOAT(NDEF-K+IONE-INTCPT),IND)
A(LSUBYI) = A(ISUBXC)
A(LSUBYN) = RR(KZ,KZ)
C
NI(NISUBL) = K
NN(NNSUBL) = K
ISUBCL = LSUBCL - IONE
ISUBRM = LSUBRM
KSUBRM = LSUBRM + 11 * (KZ - IONE)
IF (IBIT.EQ.IONE) GO TO 130
DO 120 M=1,K
MSUBCL = ISUBCL
MSUBRM = ISUBRM
DO 110 L=1,KO
IF (IBIT.EQ.ITWO) RS = FDIV (A(MSUBRM),FLOAT(NDEF-M),IND)
IF (IBIT.EQ.ITHRE) RS = A(MSUBRM) + SIG * FLOAT (M)
MSUBCL = MSUBCL + IONE
MSUBRM = MSUBRM + IONE
IF (RS.GE.A(KSUBRM)) GO TO 110
TEMP = A(MSUBCL)
CALL CPSTRE (RS,TEMP,KO,A(LSUBCL),A(LSUBRM),KZ,NV,ND)
110 CONTINUE
ISUBCL = ISUBCL + 11
ISUBRM = ISUBRM + 11
120 CONTINUE
C
130 NREG = IZERO
NCAL = ITWO
MN = ITWO
MV = -IONE
C
C STAGE LOOP.
C
140 JSUBRM = KSUBRM
IF (MN.EQ.IONE) GO TO 240
ISUBPN = NPSUBL + MN - IONE
IP = IPN(ISUBPN)
IPN(ISUBPN) = IP + IONE
MV = MV - IPN(ISUBPN+1) + IP + ITWO
ISUBPI = IPSUBL + MV - IONE
IPI(ISUBPI) = IP
MN = MN - IONE
ISUBPN = ISUBPN - IONE
IN = IPN(ISUBPN)
JC = MV
ISUBYI = LSUBYI + IP - IONE
BOUND = A(ISUBYI)
A(ISUBYI) = TWO
C
C FIND LEAP FROM BOUNDS.
C
ISUBRM = LSUBRM + LOW - IONE
KSUBRM = LSUBRM + 11 * (KZ - IONE) + LOW - IONE
DO 150 LB=IP,KM
MT = MN + KM - LB
MSUBRM = ISUBRM + 11 * (MT - IONE)
IF (IBIT.EQ.IONE .AND. A(MSUBRM).GT.BOUND) GO TO 160
IF (IBIT.EQ.ITWO .AND. A(KSUBRM).GT.FDIV(BOUND,FLOAT(NDEF-MT),
1 IND)) GO TO 160
IF (IBIT.EQ.ITHRE .AND. A(KSUBRM).GT.BOUND+SIG*FLOAT(MT))
1 GO TO 160
150 CONTINUE
GO TO 140
C
160 LC = KM + IP - LB
NREG = NREG + ITWO * (LC-IP+IONE)
IF (IP.EQ.IONE) LC = K
C
C REGRESSIONS FROM INVERSE MATRIX.
C
ISUBNI = NISUBL + IP
ISUBNN = NNSUBL + IP
KSUBLI = LISUBL + IP - IONE
KSUBLN = LNSUBL + IN - IONE
KSUBNN = NNSUBL + IN - IONE
DO 200 LB=IP,LC
LBB = LB
CALL BACK (NC(NCSUBL),LBB,LI,IPI(IPSUBL),MV,RS,BOUND,ILI(LISUBL)
1 ,JC,ID(IDSUBL),A(LSUBXI),MD(MDSUBL),
2 IONE,NI(NISUBL),ND,KZ,NL,NCAL)
C
C RE-ORDER VARIABLES.
C
M = LB
MSUBLN = KSUBLN + KZ * (M - IONE)
MSUBLI = KSUBLI + KZ * (M - IONE)
ISUBYI = LSUBYI + M - IONE
IF (LB.GT.NN(KSUBNN)) GO TO 190
LN = ILN(MSUBLN)
170 IF (RS.LE.A(ISUBYI)) GO TO 180
A(ISUBYI+1) = A(ISUBYI)
NSUBLI = MSUBLI - KZ
NSUBLN = MSUBLN - KZ
ILI(MSUBLI) = ILI(NSUBLI)
ILN(MSUBLN) = ILN(NSUBLN)
M = M - IONE
MSUBLI = MSUBLI - KZ
MSUBLN = MSUBLN - KZ
ISUBYI = ISUBYI - IONE
GO TO 170
180 ILI(MSUBLI) = LI
ILN(MSUBLN) = LN
190 A(ISUBYI+1) = RS
NI(ISUBNI) = LB
NN(ISUBNN) = LB
ISUBNI = ISUBNI + IONE
ISUBNN = ISUBNN + IONE
200 CONTINUE
IF (LC.EQ.K) LC = KM
MI = K - MV
JC = MN
C
C REGRESSIONS FROM PRODUCT MATRIX.
C
ISUBRM = LSUBRM + 11 * (MI - IONE)
KSUBRM = LSUBRM + 11 * (KZ - IONE)
ISUBCI = LSUBCI + IP - IONE
ISUBYI = LSUBYI + IP - IONE
ISUBYN = LSUBYN + IP - IONE
ISUBCO = LSUBCO - IONE
DO 230 LB=IP,LC
LBB = LB
ISUBCN = LSUBCN + IN - IONE
ISUBNC = NCSUBL + IN - IONE
KSUBYN = LSUBYN + IN - IONE
ISUBYI = ISUBYI + IONE
ISUBYN = ISUBYN + IONE
IS = LB + IONE
MSUBCN = LSUBCN + LB
A(MSUBCN) = A(KSUBYN)
CALL BACK (NC(NCSUBL),LBB,L,IPN(NPSUBL),MN,A(ISUBYN),A(MSUBCN)
1 ,ILN(LNSUBL),JC,ID(IDSUBL),A(LSUBXN),MD(MDSUBL),
2 IZERO,NN(NNSUBL),ND,KZ,NL,NCAL)
MSUBNC = ISUBNC + KZ * (L - IONE)
ISUB4 = NC(MSUBNC)
MSUBCI = LSUBCI + LB
MSUBCO = ISUBCO + ISUB4
A(MSUBCI) = A(ISUBCI) - A(MSUBCO)
A(MSUBCN) = A(ISUBCN) + A(MSUBCO)
IF (A(ISUBYI).GE.A(ISUBRM)) GO TO 210
CALL CPSTRE (A(ISUBYI),A(MSUBCI),KO,A(LSUBCL),A(LSUBRM),MI,
1 NV,ND)
IF (IBIT.EQ.IONE) GO TO 210
IF (IBIT.EQ.ITWO) RS = FDIV (A(ISUBYI),FLOAT(NDEF-MI),IND)
IF (IBIT.EQ.ITHRE) RS = A(ISUBYI) + FLOAT(MI) * SIG
IF (RS.LT.A(KSUBRM)) CALL CPSTRE (RS,A(MSUBCI),KO,A(LSUBCL),
1 A(LSUBRM),KZ,NV,ND)
210 MSUBRM = LSUBRM + 11 * (MN - IONE)
IF (A(ISUBYN).GE.A(MSUBRM)) GO TO 220
CALL CPSTRE (A(ISUBYN),A(MSUBCN),KO,A(LSUBCL),A(LSUBRM),MN,
1 NV,ND)
IF (IBIT.EQ.IONE) GO TO 220
IF (IBIT.EQ.ITWO) RS = FDIV (A(ISUBYN),FLOAT(NDEF-MN),IND)
IF (IBIT.EQ.ITHRE) RS = A(ISUBYN) + FLOAT(MN) * SIG
IF (RS.LT.A(KSUBRM)) CALL CPSTRE (RS,A(MSUBCN),KO,A(LSUBCL),
1 A(LSUBRM),KZ,NV,ND)
220 MN = MN + IONE
ISUBPN = NPSUBL + MN - IONE
IPN(ISUBPN+1) = IPN(ISUBPN) + IONE
IN = IS
230 CONTINUE
IF (LC.EQ.KM) MN = MN - IONE
GO TO 140
C
C OUTPUT.
C
240 NLINES = 8 + IDIV (KX-IONE,ITWO,IND)
ISUBCL = LSUBCL - 12
ISUBRM = LSUBRM - 12
DO 320 M=1,K
MM = M
ISUBCL = ISUBCL + 11
ISUBRM = ISUBRM + 11
IF (NLINES+ITHRE.LE.NTLINE) GO TO 250
CALL PAGE (IFOUR)
NLINES = ITHRE
250 IF (KO.GT.IONE .AND. M.EQ.IONE) WRITE (IPRINT,390)
IF (KO.GT.IONE .AND. M.GT.IONE) WRITE (IPRINT,340) M
NLINES = NLINES + ITWO
IPRTSW = IZERO
DO 310 LA=1,KO
NCOF = IONE
L = KO - LA + IONE
MSUBRM = ISUBRM + L
IF (A(MSUBRM).EQ.TWO) GO TO 320
IF (IBIT.EQ.IONE) R2 = SPCA - FDIV (A(MSUBRM),SS,IND)
IF (IBIT.EQ.ITWO) RS = FDIV (A(MSUBRM),FLOAT(NDEF-M),IND)
IF (IBIT.EQ.ITHRE) RS = A(MSUBRM) + SIG * FLOAT(M)
IF (IBIT.EQ.IONE .AND. LA.LE.MBST .OR. IBIT.GT.IONE
1 .AND. RS.LE.A(JSUBRM)) NCOF = IZERO