Post Reply 
(38G) LSQS Linear Fit & Multiple Linear Regression Programme
04-18-2015, 10:12 AM (This post was last modified: 06-15-2017 01:56 PM by Gene.)
Post: #1
(38G) LSQS Linear Fit & Multiple Linear Regression Programme
So here we have a useful programme called LSQS.

If you have a body of n vector observations & wish to fit your data in some linear relationship

a*V1+b*V2+c*V3.....=V

enter V1 in the first column of M1, V2 in the second column of M1....Vn in the nth column & V in the n+1th column.

The programme LSQS calculates the values of co-efficients a,b,c.... such that the errors in the resulting values of V are minimised.

The co-efficients are returned in Ans in Home view.

LSQS

SIZE(M1)►L1:
Ans(1)►R:
L1(2)►C:
M1►M2:
DELCOL M2;C:
SUB M3;M1;{1,C};{R,C}:
TRN(M2):
INVERSE(Ans*M2)*Ans*(M3*[1]):
Find all posts by this user
Quote this message in a reply
04-19-2015, 09:06 AM
Post: #2
RE: HP 38G: LSQS Linear Fit & Multiple Linear Regression Programme
If you want a constant in your linear regression like this

C+a*V1+b*V2+c*V3.....=V

then use the programme MLR below.

Constant & regression co-efficients are returned in Ans & M5, your data remains unchanged in M1.

MLR

M1►M4:
SIZE(M1):
MAKEMAT(1,Ans(1),1)*[1]:
ADDCOL M1;Ans;1:
RUN LSQS:
Ans►M5:
M4►M1:
M5:
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)