
C; LR-VIII-C  
C;    GENERAL LINEAR REGRESSION WITHOUT STORAGE
C;     USING MA-IX.
C; 
C;     VERSION 1   CONVERSATIONAL MODE
C;       NOTE;  FOR LARGE NOS. OF REGRESSIONS
C;    ETC.,ELIMINATE ALL FORMAT STATEMENTS
C;    WITH NUMBERS FROM 901 UPWARDS AND
C;     ALL TYPE STATEMENTS USING THEM
C;
C;      USES ENTRY CODE DEVICE TO ALLOW VARIABLE
C;     TITLES,DATES,ETC.AT START OF INPUT
C;    TYPE ANY NUMBER NOT NEEDED IN HEADINGS
C;     THEN TYPE HEADINGS,DATES,ETC.,
C;    THEN TYPE THE FIRST NUMBER AGAIN WHEN
C;      READY TO START COMPUTATION
C;  
C; 10/23/67....10/27/67 
C; 
C; LT CODE 

C; CONTROL SECN.S. PRECEDED BY FORMATS TO REDUCE
C;  FORWARD REFERENCES
C;  
C;  FORMATS 2
C; 
 900;   FORMAT(/,/,"ENTRY CODE ^")  
C; 
901;   FORMAT(/,"NO.OF REGRESSIONS ")  
902;   FORMAT(/,/,/,"NO.OF POINTS ")  
903;   FORMAT(/,"INTERCEPT CASE   0 OR 1 ")  
920;   FORMAT("PLEASE!",/,"^")  
904;   FORMAT(/,"POWER ")  
906;   FORMAT(/,/,"X & Y ") 
907;   FORMAT(/,"PLOT OR NOT?   0 OR 1 ")  
908;   FORMAT(/,"LIMITS X1,X2 & NO.OF INTERVALS ")  
909;   FORMAT(/,"STUDENT'S T & P FOR ",I,"DEGREES OF FREEDOM ")  
921;   FORMAT(/,"WEIGHTING  1=NONE; 2=POWER; 3=LOG; 4=EXP",/) 
C; 
C; LT CODE 

C; 
C; FORMATS
C; 
800;   FORMAT(I)  
801;   FORMAT(E)  
802;   FORMAT(/,/,"REGRESSION NO.",I,/,"MEAN X=",E,"MEAN Y=",E,'
             "SUM WTS.=",E,/,"SSDX=",E,"  SSDY=",E,"  SDXY=",E,/,/) 
803;   FORMAT("M=",E," S.E. ",E,/,"C=",E," S.E. ",E,/,'
              "SUM SQS.RESIDUALS=",E,/,/)  
805;   FORMAT(/,"X ",E,"EY ",E," DY ",E)  
812;   FORMAT("CORR.COEFF.=",E,/,/)  
C; 
C; 
C; LT CODE 
C; CONTROL SECN.C1
C; 
      TYPE 900  
      ACCEPT 800,IPWR  
  1;  ACCEPT 800,INTC  
     IF(INTC-IPWR)1,2,1  
C; 
  2;   TYPE 901  
      TYPE 920   
       ACCEPT 800,N1  
   ;DO 600 J=1,N1  
      INC4=0  
C;  
     TYPE 902  
     TYPE 920  
     ACCEPT 800,N2 
C; 
    TYPE 903  
    TYPE 920  
    ACCEPT 800,INTC  
C;  
    TYPE 921  
     TYPE 920  
    ACCEPT 800,IWTF  
C;   
  IF(IWTF-2)4,3,4  
3;    TYPE 904  
      TYPE 920  
      ACCEPT 800,IPWR  
C; 
C; CONTROL SECN.C2  
C; 
  4;     TYPE 906 
      TYPE 920 
400; INC4=INC4+1  
     GO TO(501,503,401,432),INC4  
C;LT CODE 


C; MAIN ARITHMETIC-IX 
C; 
C;   CUMULATIVE CALCULATION OF MEANS,SUMS OF SQUARES,ETC.
C;   WITHOUT STORAGE BASED ON D.CALHOUN'S SUGGESTION
C;   1965.SEE ALSO SAPEGA(1967,DECUSCOPE,VOL.6,NO.3)
C;   FOR UNWEIGHTED VERSION.
C;  
C;   MOD...........10/26/67
C; LT CODE 


C; SECTION MA-1A
C;       INITIALIZING,ETC.
C; 
 501;    EN2=N2  
     XBAR=YBAR=SWT=SSDX=SSDY=SDXY=0.0  
   ;DO 510 I=1,N2 
       WT=1.0  
C; LAST STATEMENT GIVES UNWEIGHTED CASE
C; LT CODE 

C; SECTION MA-1B
C;      INPUT OF X AND Y.CAN INCLUDE ANY TRANSFORMATIONS
C;      IF NEEDED,E.G. Y=LOGF(Y). TO PROTECT AGAINST
C;      NEGATIVE VALUES USE SECTION SIMILAR TO
C;      START OF SECN.1C BELOW.
C; 
    ACCEPT 801,X,Y  
C; 
C; LT CODE 

C; SECTION MA-1C 
C;      WEIGHTING FUNCTIONS
C;   EXITS WITH WT ONLY MODIFIED FROM 1.0 IF WEIGHTING ASKED FOR
C; 
   IF(Y)551,552,552  
551;   DUM1=-Y  
      GO TO 553  
552;   DUM1=Y  
553;  GO TO(502,554,555,556),IWTF  
C;  
554;    WT=DUM1**IPWR  
     GO TO 502  
555;    WT=LOGF(DUM1)  
      GO TO 502  
556;    WT=EXPF(DUM1)  
C; 
C; LT CODE 


C; SECTION MA-1D
C;     MAIN CALCULATIONS  
C; 
502;   SWT=SWT+WT  
      DUM1=X-XBAR  
       DUM2=Y-YBAR  
      DUM3=(SWT-WT)/SWT  
      DUM4=WT/SWT  
      SSDX=SSDX+DUM3*DUM1*DUM1  
      SSDY=SSDY+DUM3*DUM2*DUM2 
      SDXY=SDXY+DUM3*DUM1*DUM2  
      XBAR=XBAR*DUM3+X*DUM4  
      YBAR=YBAR*DUM3+Y*DUM4  
510;CONTINUE  
C; 
   GO TO 400  
C; 
C; LT CODE 

C; SECTION MA-2 
C;    REGRESSION COEFFICIENTS,ETC.
C;  
C;  SUBSECTION FOR CASE OF C KNOWN TO BE ZERO
C; 
503;  GO TO(511),INTC  
C; 
      EN2=EN2+1.0  
     SSDX=SSDX+SWT*XBAR*XBAR  
     SSDY=SSDY+SWT*YBAR*YBAR  
     SDXY=SDXY+SWT*XBAR*YBAR  
C;  GENERAL CASE OF C NOT KNOWN TO BE ZERO
C; 
 511;   EM=SDXY/SSDX  
        CNST=YBAR-EM*XBAR  
        SSRS=SSDY-EM*SDXY  
        DUM2=SQTF(SSRS/SSDX/(EN2-1.0))  
        DUM3=SQTF(SSRS/(EN2-2.0)*(1.0/SWT+XBAR*(XBAR/SSDX))) 
        DUM4=SDXY/SQTF(SSDX*SSDY)  
   GO TO 400  
C; 
C; LT CODE 

C; SECTION MA-3 
C;    CONFIDENCE LIMITS AS VARIANCE 
C; 
 504;  DUM2=DUM1-XBAR  
       DUM4=(SSRS/(EN2-2.0))*(1.0+(1.0/SWT)+DUM2*(DUM2/SSDX))  
    GO TO 400  
C; 
C; LT CODE 

C; CONTROL SECN. C3  
C; TYPE MEANS,WEIGHTS,ETC.
C;  
 401;    TYPE 802,J,XBAR,YBAR,SWT,SSDX,SSDY,SDXY  
         TYPE 803,EM,DUM2,CNST,DUM3,SSRS  
         TYPE 812,DUM4  
C; 
C; PLOT CONFIDENCE LIMITS ,ETC.IF WANTED
C; 
       TYPE 907 
       TYPE 920  
       ACCEPT 800,IWTF  
    GO TO(402),IWTF  
     GO TO 600  
402;   TYPE 908 
       TYPE 920 
      ACCEPT 801,ELM1,ELM2  
      ACCEPT 800,INTC  
      N2=N2-1  
      TYPE 909,N2 
      TYPE 920  
      ACCEPT 801,STN2,DUM2  
403;  EINT=INTC  
      DUM5=(ELM2-ELM1)/EINT  
      DUM1=ELM1-DUM5  
       I=0  
431; INC4=3  
      DUM1=DUM1+DUM5  
     GO TO 504  
432;  DUM4=SQTF(DUM4)*STN2  
      DUM3=DUM1*EM+CNST  
      TYPE 805,DUM1,DUM3,DUM4  
   I=I+1  
   IF(I-INTC)431,431,600   
C; 
C; CONTROL SECN.C7 
C; 
600;CONTINUE  
      STOP 
C; 
C; LT CODE 

C;  
   END



