BBS: Inland Empire Archive Date: 04-11-92 (17:14) Number: 11 From: JEAN CREPEAU Refer#: NONE To: DON KROUSE Recvd: NO Subj: Regression Conf: (2) Quik_Bas

In a message to ALL, DON KROUSE wrote: DK=> Hi Folks, DK=> Does anyone know were I might find source code for a multiple regression routine? DK=> I am particularly interested in a routine that does Linear, Log, Exponential, Power, etc. and that optimizes the order in which the dependent variables are included. Use the following formula m=(n*SUM(x*y) - SUM(x)*(SUM(y))/(n*SUM(x*x) - SUM(x)*SUM(x)) b=(SUM(y)-m*SUM(x))/n where n=# of samples Your linear equation is y=mx+b Here is the source:TYPERECT XASSINGLEYASSINGLEENDTYPESUBREGR(N,VEC()ASRECT,MODE,M,B)FORX=0TON-1IFMODEAND1THENCX=LOG(VEC(X).X)ELSECX=VEC(X).XIFMODEAND2THENCY=LOG(VEC(X).Y)ELSECY=VEC(X).Y SX=SX+CX:SY=SY+CY:SXY=SXY+CX*CY:SX2=SX2+CX*CXNEXTM=(N*SXY-SX*SY)/(N*SX2-SX*SX) B=(SY-M*SX)/NENDSUBThis sub calculates m and b from a list of points vec(0...n-1). It has been modified to compute linear, log, exp and power regression. To use it: 1. You put the data in a vector of type RECTINPUT"NUMBER OFDATA: ",NREDIMVEC(N-1)ASRECTFORX=0TON-1INPUT"(X,Y): ",VEC(X).X,VEC(X).YNEXT2. You determine the mode MODE=0 => linear MODE=1 => log MODE=2 => exp MODE=3 => power 3. You call the sub REGR N,VEC(),MODE,M,B 4. Your regression equation is Mode 0: y=m*x+b Mode 1: y=m*log x + b Mode 2: y=exp(b)*exp(m*x) Mode 3: y=exp(b)*x^m --- * Origin: INTERACESS Montreal (QC) Canada (514) 528-1415 (1:167/280)

Echo Basic Postings

**Books at Amazon:**

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET