HP Forums
Simple Logistic Regression - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP Prime Software Library (/forum-15.html)
+--- Thread: Simple Logistic Regression (/thread-8205.html)



Simple Logistic Regression - Eddie W. Shore - 04-19-2017 11:44 AM

The program SIMPLOGI attempts to fit two lists of data (X, Y) to the equation:

y = 1 / (A + B*e^(-x))

by using the translation: X’ = e^-X and Y’ = 1/Y and performing linear regression analysis on X’ and Y’. This is good for all data except when y = 0.

Code:
EXPORT SIMPLOGI(L1,L2)
BEGIN
// EWS 2017-04-18

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

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=1/(A+Be^(−X))",M3};

END;