HP Forums

Full Version: Syntax Error with “Sn” Argument in Statistics 2Var Functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am getting syntax errors for the first argument (Sn) when I call Statistics 2Var functions such as SetDepend(Sn,Cm) or Do2VStats(Sn). There were no such errors prior to the latest firmware update. Did the syntax change? The User Guide is from December, 2017, so I can’t tell if there was a change. Is there a correct syntax or work-around?

I just tested it and it seemed to work fine here. Is your 2Var stat the active one? If not, you might need to qualify it.
See if you have the Sn checked; an unchecked Sn won't calculate.

Syntax: CHECK(n)
Tim, I do not assume that the app is the current app so I always qualify the function calls and variable references. Eddie, thanks for reminding me to be sure that the S1 is enabled.

All is well for now - thanks very much!
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:


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

EXPORT AICc(sse,n,p)
  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);

EXPORT RSqrAdj(rSqr,n,p)
  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));

EXPORT FitEval(f,c)
  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.S1(1) := "C1";
  Statistics_2Var.S1(2) := "C2";
  Statistics_2Var.S1(4) := f;
  IF f == 7 THEN L := 0 END;
    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));
    IF c == 2 THEN
      IFERR r2 := Statistics_2Var.CoefDet THEN
        criterion := "Error";
        IF Statistics_2Var.NbItem > p(f) THEN
          criterion := RSqrAdj(Statistics_2Var.CoefDet,Statistics_2Var.NbItem,p(f));
  STARTAPP("Statistics 2Var");
  RETURN criterion;
Reference URL's