Post Reply 
Square Root Linear Regression
07-16-2017, 11:40 PM
Post: #1
Square Root Linear Regression
The program SQLINREG attempts to fit data to the curve:

Y = √(A + B*X)

We can use the linear transformation:

y^2 = a + b*x

This allows us to enter each data point as (x, y^2) and execute the linear regression function. The HP Prime version uses the LSQ function. Both the Casio fx-CG50 and TI-84 Plus CE versions give the correlation, r.
Code:

EXPORT SQLINREG(L1,L2)
BEGIN
// EWS 2017-07-16
// Square Root-Linear Regression
// Y=√(A+BX)

LOCAL S:=SIZE(L1);
LOCAL L0:=MAKELIST(1,X,1,S);
L2:=L2^2;

LOCAL M1,M2,M3;
M1:=list2mat(CONCAT(L0,L1),S);
M1:=TRN(M1);
M2:=list2mat(L2,S);
M2:=TRN(M2);
M3:=CAS.LSQ(M1,M2);

RETURN 
{"Y=√(A+BX)",M3};

END;

Example:

x y y^2
0.9 2.40 5.76
1.3 2.68 7.1824
1.8 3.03 9.1809
2.4 3.39 11.4921
3.6 4.05 16.4025
5.2 4.77 22.7529
6.1 5.14 26.4196

Results:
A = 2.03165434
B = 3.989146461

Equation: y = √(2.03165434 + 3.98914641*x)


Predicted Values:
y(2) = 3.163850053
y(4) = 4.241254529
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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