The $check_syntax() method of a CmdStanModel object
checks the Stan program for syntax errors and returns TRUE (invisibly) if
parsing succeeds. If invalid syntax in found an error is thrown.
check_syntax( pedantic = FALSE, include_paths = NULL, stanc_options = list(), quiet = FALSE )
| pedantic | (logical) Should pedantic mode be turned on? The default is
|
|---|---|
| include_paths | (character vector) Paths to directories where Stan
should look for files specified in |
| stanc_options | (list) Any other Stan-to-C++ transpiler options to be
used when compiling the model. See the documentation for the
|
| quiet | (logical) Should informational messages be suppressed? The
default is |
The $check_syntax() method returns TRUE (invisibly) if the model
is valid.
The CmdStanR website (mc-stan.org/cmdstanr) for online documentation and tutorials.
The Stan and CmdStan documentation:
Stan documentation: mc-stan.org/users/documentation
CmdStan User’s Guide: mc-stan.org/docs/cmdstan-guide
Other CmdStanModel methods:
model-method-compile,
model-method-diagnose,
model-method-format,
model-method-generate-quantities,
model-method-optimize,
model-method-sample_mpi,
model-method-sample,
model-method-variables,
model-method-variational
# \dontrun{ file <- write_stan_file(" data { int N; int y[N]; } parameters { // should have <lower=0> but omitting to demonstrate pedantic mode real lambda; } model { y ~ poisson(lambda); } ") mod <- cmdstan_model(file, compile = FALSE) # the program is syntactically correct, however... mod$check_syntax()#> #> #> #> #>#># pedantic mode will warn that lambda should be constrained to be positive # and that lambda has no prior distribution mod$check_syntax(pedantic = TRUE)#> #> #> #> #> #> #> #> #>#># }