Post Reply 
Syntax Error with “Sn” Argument in Statistics 2Var Functions
11-16-2018, 12:33 PM
Post: #5
RE: Syntax Error with “Sn” Argument in Statistics 2Var Functions
I was able to eliminate the syntax errors by changing S1 variable to a string "S1" in the function call. But now I get an invalid input error from the function call. If I remove the double quotation marks, I get a syntax error from the compiler. Here is the code:

Code:

#pragma mode( separator(.,;) integer(h32) )

EXPORT AICc(sse,n,p)
BEGIN
  IF NOT sse > 0 THEN MSGBOX("SSE must be greater than zero"); RETURN "Error"; END;
  IF NOT n > (p+2) THEN MSGBOX("n must be greater than p by 2"); RETURN "Error"; END;
  IF NOT p > 0 THEN MSGBOX("p must be greater than zero"); RETURN "Error"; END;
  // AICc for continuous, real response
  RETURN n * LN( 2 * Pi() * sse / n ) + (n + p) / (1 - (p + 2) / n);
END;

EXPORT RSqrAdj(rSqr,n,p)
BEGIN
  IF NOT rSqr > 0 AND NOT rSqr<1 THEN MSGBOX("R square must be in interval (0,1)"); RETURN "Error"; END;
  IF NOT n > 2 THEN MSGBOX("n must be greater than 2"); RETURN "Error"; END;
  IF NOT n > p THEN MSGBOX("n must be greater than p"); RETURN "Error"; END;
  IF NOT p > 0 THEN MSGBOX("p must be positive"); RETURN "Error"; END;
  // R square adjusted (penalized) for number of parameters
  RETURN 1-((n-1)*(1-rSqr)/(n-p));
END;

EXPORT FitEval(f,c)
BEGIN
  IF f < 1 OR f > 12 THEN MSGBOX("f must be index 1-12"); RETURN "Error"; END;
  IF NOT (c == 1 OR c == 2) THEN MSGBOX("c must be index 1 or 2"); RETURN "Error"; END;
  LOCAL sse,criterion,r2;
  LOCAL p := {2,2,2,2,2,2,3,3,4,5,4,2};
  Statistics_2Var.CHECK(1);
  Statistics_2Var.S1(1) := "C1";
  Statistics_2Var.S1(2) := "C2";
  Statistics_2Var.S1(4) := f;
  IF f == 7 THEN L := 0 END;
  Statistics_2Var.Do2VStats("S1");
  CASE
    IF c == 1 THEN
      sse := ΣLIST(Statistics_2Var.Resid("S1")^2);
      IF sse > 0 AND Statistics_2Var.NbItem > (p(f)+2) THEN
        criterion := AICc(sse,Statistics_2Var.NbItem,p(f));
      END;
    END;
    IF c == 2 THEN
      IFERR r2 := Statistics_2Var.CoefDet THEN
        criterion := "Error";
        BREAK;
      ELSE
        IF Statistics_2Var.NbItem > p(f) THEN
          criterion := RSqrAdj(Statistics_2Var.CoefDet,Statistics_2Var.NbItem,p(f));
        END;
      END;
    END;
  END;
  STARTAPP("Statistics 2Var");
  STARTVIEW(1,1);
  RETURN criterion;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Syntax Error with “Sn” Argument in Statistics 2Var Functions - mark4flies - 11-16-2018 12:33 PM



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