The $format() method of a CmdStanModel object
runs stanc's auto-formatter on the model code. Either saves the formatted
model directly back to the file or prints it for inspection.
format( overwrite_file = FALSE, canonicalize = FALSE, backup = TRUE, max_line_length = NULL, quiet = FALSE )
| overwrite_file | (logical) Should the formatted code be written back
to the input model file. The default is |
|---|---|
| canonicalize | (list or logical) Defines whether or not the compiler
should 'canonicalize' the Stan model, removing things like deprecated syntax.
Default is |
| backup | (logical) If |
| max_line_length | (integer) The maximum length of a line when formatting.
The default is |
| quiet | (logical) Should informational messages be suppressed? The
default is |
The $format() 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-check_syntax,
model-method-compile,
model-method-diagnose,
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 { real lambda; } model { target += poisson_log(y | lambda); } ") mod <- cmdstan_model(file, compile = FALSE) mod$format(canonicalize = TRUE)#> #> #> #> #> #> #> #> #> #> #>#> Error: Syntax error found! See the message above for more information.# }