7.7 Conditional statements
Stan supports full conditional statements using the same if-then-else syntax as C++. The general format is
if (condition1)
statement1else if (condition2)
statement2// ...
else if (conditionN-1)
-1
statementNelse
statementN
There must be a single leading if
clause, which may be followed
by any number of else if
clauses, all of which may be
optionally followed by an else
clause. Each condition must be
an integer value, with non-zero values interpreted as true and
the zero value as false.
The entire sequence of if-then-else clauses forms a single conditional statement for evaluation. The conditions are evaluated in order until one of the conditions evaluates to a non-zero value, at which point its corresponding statement is executed and the conditional statement finishes execution. If none of the conditions evaluate to a non-zero value and there is a final else clause, its statement is executed.