Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0020/stat21.sta
There are 2 other files named stat21.sta in the archive. Click here to see a list.
100'  NAME--STAT21
110' 
120'  DESCRIPTION--COMPUTES ONE OR MORE MULTIPLE LINEAR REGRESSIONS
130'  ON A BATCH OF DATA.
140'
150'  SOURCE--REVISED 11/16/67 BY PROF. GERALD CHILDS.
160'
170'  INSTRUCTIONS--PLACE DATA IN LINE 1960 AND FOLLOWING.
180'  FIRST DATA IS N (NUMBER OF DATA SETS OR OBSERVATIONS), 
190'  THEN V(NUMBER OF VARIABLES IN DATA BATCH),THEN G
200'  (NUMBER OF REGRESSIONS TO BE PERFORMED). THEN ENTER THE
210'  DATA BY THE DATA SET, THAT IS ENTER FIRST THE VALUES FOR
220'  ALL VARIABLES AT OBSERVATION 1, THEN THE VALUES FOR THE
230'  VARIABLES FOR OBSERVATION 2 ETC.VARIABLES MAY BE
240'  ENTERED IN ANY ORDER,BUT THE ORDER MUST BE THE SAME FOR EACH
250'  DATA SET. THE POSTITION OF A VARIABLE IN ENTERING THE DATA IS 
260'  THE INDEX OF THE VARIABLE.THUS, IF THERE ARE 4 VARIABLES
270'  ENTERED IN THE ORDER X,Y,Z,W, THE INDEX OF Z IS 3.  NEXT,
280'  FOR EACH REGRESSION ENTER(IN ORDER) H(THE NUMBER OF THE
290'  REGRESSION),THEN K(TOTAL NUMBER OF INDEPENDENT VARIABLES
300'  IN THIS REGRESSION), THEN P1(ENTER 1 IF YOU WANT THE VARIANCE-
310'  COVARIANCE MATRIX PRINTED OUT, OTHERWISE ENTER  0),
320'  THEN P2(ENTER 1 IF YOU WANT THE RESIDUALS PRINTED OUT,OTHERWISE
330'  ENTER 0),AND THEN ENTER THE INDEXES OF THE INDEPENDENT
340'  VARIABLES FOLLOWED BY THE INDEX OF THE DEPENDENT VARIABLE.
350'  IF N>211 OF V>17, THEN THE DIM STATEMENTS IN LINES 510 AND 520
360'  MUST BE CHANGED.
370'  SAMPLE DATA ARE IN LINES 1960 THROUGH 2190.
380'  BE SURE TO REMOVE THE SAMPLE DATA BEFORE RUNNING THE PROGRAM.
390'  
400'  THE FOLLOWING RESTRICTION APPLIES TO THE NUMBER OF
405'  DATA SETS(N) AND THE NUMBER OF VARIABLES (V):
410'
420'     N IS THE LARGEST INTEGER FOR WHICH N IS LESS THAN
430'     OR EQUAL TO :
440'                   5354-V (5V+6)
450'                   --------------
460'                      1 + V
470'
480'
490'  *  *  *  *  *  *   MAIN PROGRAM  *  *  *  *  *  *  *  *  *
500'
510  DIM X(17,17),A(17,17),D(211,17),Y(17),M(17),S(17)
520  DIM T(17),B(17),U(17,17),R(17,17),C(17,17),Q(211),E(17)
530  READ N, V, G
540 MAT READ D(N,V)
550 FOR I=1 TO N
560  LET D(I,0)=1
570 NEXT I
580  READ H, K, P1, P2
590 LET M = K + 1
600   MAT READ E(M)
610 PRINT "**REGRESSION NUMBER"H":DEPENDENT VARIABLE IS"E(M)
620 PRINT
630 IF H>1 THEN 780
640 FOR I=0 TO V
650  FOR J=0 TO V
660     LET X=0
670   FOR L=1 TO N
680       LET X=X+D(L,I)*D(L,J)
690 NEXT L
700    LET X(I,J)=X
710      LET C(I,J)=X
720   NEXT J
730  LET T(I)=X(0,I)/X(0,0)
740 LET B(I)=0
750 IF I=0 THEN 770
760 LET B(I)=SQR(X(I,I)/(N-1)-X(0,I)*X(0,I)/(N*(N-1)))
770 NEXT I
780 PRINT "INDEX", "MEANS", "STANDARD DEVIATIONS"
790 FOR I=1 TO M
800 LET M(I)=T(E(I))
810 LET S(I)=B(E(I))
820 PRINT E(I), M(I), S(I)
830 NEXT I
840 PRINT
850 PRINT
860 PRINT "CORRELATION COEFFICIENTS"
870  IF H>1 THEN 930
880 FOR I=1 TO V
890  FOR J=1 TO V
900   LET R(I,J)=(N*X(I,J)-X(0,I)*X(0,J))/(N*(N-1)*B(I)*B(J))
910  NEXT J
920 NEXT I
930 FOR I=1 TO M
940   FOR J=1 TO M
950     LET U(I,J)=R(E(I),E(J))
960   PRINT U(I,J),
970   NEXT J
980 PRINT
990 PRINT
1000 NEXT I
1010 PRINT
1020 LET E(0)=0
1030 FOR I=0 TO K
1040  LET Y(I)=C(E(I),E(M))
1050   FOR J=0 TO K
1060    LET X(I,J)=C(E(I),E(J))
1070   NEXT J
1080 NEXT I
1090 FOR I=0 TO K
1100  FOR J=0 TO K
1110   IF I<>J THEN 1140
1120   LET A(I,J)=1
1130   GO TO 1150
1140   LET A(I,J)=0
1150  NEXT J
1160 NEXT I
1170 FOR I=0 TO K
1180 IF X(I,I)<1E-6 THEN 1920
1190  LET Y(I)=Y(I)/X(I,I)
1200   FOR J=0 TO K
1210    LET A(I,J)=A(I,J)/X(I,I)
1220    IF J=I THEN 1240
1230    LET X(I,J)=X(I,J)/X(I,I)
1240   NEXT J
1250  LET X(I,I)=1
1260   FOR L=0 TO K
1270    IF L=I THEN 1350
1280    LET Y(L)=Y(L)-X(L,I)*Y(I)
1290     FOR J=0 TO K
1300      LET A(L,J)=A(L,J)-X(L,I)*A(I,J)
1310      IF J=I THEN 1330
1320      LET X(L,J)=X(L,J)-X(L,I)*X(I,J)
1330     NEXT J
1340    LET X(L,I)=0
1350   NEXT L
1360 NEXT I
1370 LET S6=C(E(M),E(M))
1380 FOR I=0 TO K
1390   LET S6=S6-Y(I)*C(E(I),E(M))
1400 NEXT I
1410 LET S7=S6/(N-M)
1420 LET R2=1-S7/(S(M)*S(M))
1430 LET R=SQR(R2)
1440 LET S8=SQR(S7)
1450 IF P1=0 THEN 1470
1460 PRINT "VARIANCE-COVARIANCE MATRIX"
1470 FOR I=0 TO K
1480   FOR J=0 TO K
1490  LET A(I,J)=A(I,J)*S7
1500  IF P1=0 THEN 1520
1510 PRINT A(I,J),
1520  NEXT J
1530 IF P1=0 THEN 1560
1540  PRINT
1550  PRINT
1560 NEXT I
1570 PRINT
1580 PRINT "INDEX", "B", "STD. ERROR", "T-RATIO"
1590 FOR I=0 TO K
1600 PRINT E(I), Y(I), SQR(A(I,I)), Y(I)/SQR(A(I,I))
1610 NEXT I
1620 PRINT
1630 PRINT "R-SQUARED=" R2, "R=" R
1640 PRINT
1650 PRINT "STAND. ERROR OF EST.=";S8,"D.F.=";(N-M)
1660 PRINT
1670 FOR I=1 TO N
1680  LET Z=D(I,E(M))-Y(0)
1690   FOR J=1 TO K
1700   LET Z=Z-Y(J)*D(I,E(J))
1710   NEXT J
1720 LET Q(I)=Z
1730 NEXT I
1740 LET W=0
1750 FOR I=2 TO N
1760 LET W=W+(Q(I)-Q(I-1))*(Q(I)-Q(I-1))
1770 NEXT I
1780 PRINT
1790 IF P2=0 THEN 1860
1800 PRINT "ACTUAL", "PREDICTED", "RESIDUAL"
1810 LET I = 0
1820 LET I = I + 1
1830  PRINT D(I,E(M)), D(I,E(M))-Q(I), Q(I)
1840 IF I = N THEN 1860
1850 GO TO 1820
1860 PRINT
1870 PRINT "DURBIN-WATSON STAT.=" W/S6
1880 IF H<G THEN 1900
1890 GO TO 1930
1900 PRINT
1910  GO TO 580
1920 PRINT "CORRELATION MATRIX BECOMING SINGULAR"
1930 PRINT
1940 PRINT "     *****PROBLEM COMPLETED*****"
1950 STOP
1960 DATA 15, 4, 4
1970 DATA 32, 48, 54, 15
1980 DATA 36, 33, 19, 16
1990 DATA  3, 28, 30, 14
2000 DATA 12, 33, 64, 22
2010 DATA 36, 34, 60, 24
2020 DATA 24, 36, 53, 19
2030 DATA 19, 42, 29, 13
2040 DATA 20, 33, 55, 15
2050 DATA 27, 36, 62, 23
2060 DATA 15, 22, 33, 12
2070 DATA 45, 46, 68, 25
2080 DATA  9, 28, 42, 17
2090 DATA 11, 32, 45, 18
2100 DATA 33, 34, 39, 19
2110 DATA 21, 45, 39, 18
2120 DATA 1,1,1,1
2130 DATA 3,4
2140 DATA 2,2,1,0
2150 DATA 1,3,4
2160 DATA 3,3,0,1
2170 DATA 1,2,3,4
2180 DATA 4,1,0,0
2190 DATA 4,3
2200END