Trailing-Edge
-
PDP-10 Archives
-
decuslib10-01
-
43,50144/colinr.src
There are no other files named colinr.src in the archive.
00700 READ W9
00702 IF W9=4E37 THEN 896
00704 RESTORE
00706 PRINT
00708 PRINT "S I M P L E L I N E A R R E G R E S S I O N"
00710 PRINT
00712 PRINT " EQUATION: Y = A + B*X"
00714 PRINT
00716 PRINT
00718 DIM U(250),V(250)
00720 PRINT "HOW MANY OBSERVATIONS ON EACH VARIABLE";
00722 INPUT N
00724 PRINT
00726 PRINT
00728 IF N>2 THEN 734
00730 PRINT "MUST HAVE THREE OR MORE OBSERVATIONS."
00732 STOP
00734 LET S1=0
00736 LET S2=0
00738 LET S3=0
00740 LET S4=0
00742 LET S5=0
00744 FOR I=1 TO N
00746 READ V(I)
00748 NEXT I
00750 FOR I=1 TO N
00752 READ U(I)
00754 LET S1=S1+U(I)
00756 LET S2=S2+U(I)^2
00758 LET S3=S3+V(I)
00760 LET S4=S4+V(I)^2
00762 LET S5=S5+U(I)*V(I)
00764 NEXT I
00766 LET M1=S1/N
00768 LET M2=S3/N
00770 LET D1=S2/N-M1^2
00772 LET D2=S4/N-M2^2
00774 LET D3=S5/N-M1*M2
00776 LET C1=N*D1
00778 PRINT "VARIABLE","MEAN","VARIANCE","STD DEVIATION"
00780 PRINT
00782 PRINT " X",M1,D1,SQR(D1)
00784 PRINT " Y",M2,D2,SQR(D2)
00786 PRINT
00788 PRINT
00790 LET R8=0
00792 LET B=D3/D1
00794 LET A=M2-B*M1
00796 LET D4=D2-B*D3
00798 IF D4<D2 THEN 806
00800 LET R8=1
00802 LET R2=0
00804 GOTO 808
00806 LET R2=1-(D4/D2)
00808 PRINT "INDEX (R^2)","EXPL VAR","UNEXPL VAR","STD ERROR"
00810 PRINT
00812 IF R8=0 THEN 818
00814 PRINT " ZERO (STD ERROR OF ESTIMATE EXCEEDS STD DEV OF Y)"
00816 GOTO 820
00818 PRINT R2,D2-D4,D4,SQR(D4)
00820 PRINT
00822 PRINT
00823 LET D4=N*D4/(N-2)
00824 LET T=1.95996+2.37226/(N-2)+2.82250/(N-2)^2
00826 LET D5=SQR(D4/C1)
00828 LET D6=SQR(D4/N)
00830 LET B1=B-T*D5
00832 LET B2=B+T*D5
00834 LET A1=A-T*D6
00836 LET A2=A+T*D6
00838 PRINT "PARAMETER"," VALUE","95 PCT CONFIDENCE LIMITS"
00840 PRINT
00842 PRINT " A",A,A1,A2
00844 PRINT " B",B,B1,B2
00846 PRINT
00848 PRINT
00850 PRINT "ESTIMATED VALUES OF Y (FROM THE REGRESSION) AND CONFIDENCE"
00852 PRINT "LIMITS FOR INDIVIDUAL VALUES OF Y, FOR EACH VALUE OF X:"
00854 PRINT
00856 PRINT "X-ACTUAL","Y-ACTUAL","Y-CALC",
00858 PRINT "95 PCT CONFIDENCE LIMITS"
00860 PRINT
00862 DEF FNA(V)=SQR(D4*(1+C2+((V-M1)^2)/C1))
00864 LET C2=1/N
00866 FOR I=1 TO N
00868 LET D7=FNA(U(I))
00870 LET Y=A+B*U(I)
00872 LET C3=T*D7
00874 PRINT U(I),V(I),Y,Y-C3,Y+C3
00876 NEXT I
00878 PRINT
00880 READ X
00882 IF X=4E37 THEN 900
00884 LET D8=FNA(X)
00886 LET C4=T*D8
00888 LET Y=A+B*X
00890 PRINT X," ",Y,Y-C4,Y+C4
00892 GOTO 880
00894 DATA 4E37
00896 PRINT
00898 PRINT "LIST THE FILE 'STADES***' FOR INSTRUCTIONS."
00900 END