10 PRINT "MULTIPLE LINEAR REGRESSION"
20 PRINT
29 REM - SET ARRAY LIMITS TO X(n+1),S(n+1),T(n+1),A(n+1,N+2)
30 DIM X(9),S(9),T(9),A(9,10)
40 PRINT "NUMBER OF KNOWN POINTS";
50 INPUT N
60 PRINT "NUMBER OF INDEPENDENT VARIABLES";
70 INPUT V
80 X(1)=1
90 FOR I=1 TO N
100 PRINT "POINT";I
110 FOR J=1 TO V
119 REM - ENTER INDEPENDENT VARIABLES FOR EACH POINT
120 PRINT "  VARIABLE";J;
130 INPUT X(J+1)
140 NEXT J
149 REM - ENTER DEPENDENT VARIABLE FOR EACH POINT
150 PRINT "  DEPENDENT VARIABLE";
160 INPUT X(V+2)
169 REM - POPULATE A MATRIX TO BE USED IN CURVE FITTING
170 FOR K=1 TO V+1
180 FOR L=1 TO V+2
190 A(K,L)=A(K,L)+X(K)*X(L)
200 S(K)=A(K,V+2)
210 NEXT L
220 NEXT K
230 S(V+2)=S(V+2)+X(V+2)[2
240 NEXT I
248 REM - STATEMENTS 250 TO 500 FIT CURVE BY SOLVING THE SYSTEMOF
249 REM - LINEAR EQUATIONS IN MATRIX A()
250 FOR I=2 TO V+1
260 T(I)=A(1,I)
270 NEXT I
280 FOR I=1 TO V+1
290 FOR J=I TO V+1
300 IF A(J,I)<>0 THEN 340
310 NEXT J
320 PRINT "NO UNIQUE SOLUTION"
330 GOTO 810
340 FOR K=1 TO V+2
350 B=A(I,K)
360 A(I,K)=A(J,K)
370 A(J,K)=B
380 NEXT K
390 Z=1/A(I,I)
400 FOR K=1 TO V+2
410 A(I,K)=Z*A(I,K)
420 NEXT K
430 FOR J=1 TO V+1
440 IF J=I THEN 490
450 Z=-A(J,I)
460 FOR K=1 TO V+2
470 A(J,K)=A(J,K)+Z*A(I,K)
480 NEXT K
490 NEXT J
500 NEXT I
510 PRINT
520 PRINT "EQUATION COEFFICIENTS:"
525 PRINT "     CONSTANT:";A(1,V+2)
530 FOR I=2 TO V+1
540 PRINT "VARIABLE(";I-1;"):";A(I,V+2)
550 NEXT I
560 P=0
570 FOR I=2 TO V+1
580 P=P+A(I,V+2)*(S(I)-T(I)*S(1)/N)
590 NEXT I
600 R=S(V+2)-S(1)[2/N
610 Z=R-P
620 L=N-V-1
630 I=P/V
640 PRINT
650 I=P/R
660 PRINT "COEFFICIENT OF DETERMINATION (r[2) =";I
670 PRINT "COEFFICIENT OF MULTIPLE CORRELATION =";SQR(I)
680 PRINT "STANDARD ERROR OF ESTIMATE "; SQR(ABS(Z/L))
690 PRINT
699 REM - ESTIMATE DEPENDENT VARIABLE FROM ENTERED INDEPENDENT VARIABLES
700 PRINT "INTERPOLATION: (ENTER 0 TO END PROGRAM)"
710 P=A(1,V+2)
720 FOR J=1 TO V
730 PRINT "VARIABLE";J;
740 INPUT X
749 REM - TEST FOR END OF PROGRAM
750 IF X=0 THEN 810
760 P=P+A(J+1,V+2)*X
770 NEXT J
780 PRINT "DEPENDENT VARIABLE =";P
790 PRINT
800 GOTO 710
810 END
