HP Forums
Programming Question for Stats - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Programming Question for Stats (/thread-3911.html)



Programming Question for Stats - Eddie W. Shore - 05-19-2015 02:38 AM

Goal: Develop a program that determines the best fit between various regression types (the first six: Linear, Logarithmic, Exponential, Power, Exponent, Inverse).

However, I am getting the same correlation for each of the types. Here is the code (FW 7820):

Code:
EXPORT BESTFIT(xlist,ylist)
BEGIN
// 2015-05-15 EWS
// 2015-05-18 
LOCAL clist,k,m,p,c;

STARTAPP("Statistcs2Var");
C1:=xlist;
C2:=ylist;

S1(1):='C1';
S1(2):='C2';
 
CHECK(1);
clist:={};

// testing
FOR k FROM 1 TO 6 DO
S1(4):=k;
Do2VStats(S1);
c:=CoefDet;
// during execution c
// is the same despite
// type being changed
clist:=CONCAT(clist,{c});
END;

//find and display results
m:=MAX(clist);
p:=POS(clist,m);
S1(4):=p;
Do2VStats(S1);
// My intended results
//RETURN "Type: "+STRING(p)
//+", Coef: "+STRING(Corr,2,4);

RETURN clist;

END;

Advice?