cmdstanr_example | R Documentation |
Fit models for use in examples
cmdstanr_example(
example = c("logistic", "schools", "schools_ncp"),
method = c("sample", "optimize", "laplace", "variational", "pathfinder", "diagnose"),
...,
quiet = TRUE,
force_recompile = getOption("cmdstanr_force_recompile", default = FALSE)
)
print_example_program(example = c("logistic", "schools", "schools_ncp"))
example |
(string) The name of the example. The currently available examples are
To print the Stan code for a given |
method |
(string) Which fitting method should be used? The default is
the |
... |
Arguments passed to the chosen |
quiet |
(logical) If |
force_recompile |
Passed to the $compile() method. |
The fitted model object returned by the selected method
.
## Not run:
print_example_program("logistic")
fit_logistic_mcmc <- cmdstanr_example("logistic", chains = 2)
fit_logistic_mcmc$summary()
fit_logistic_optim <- cmdstanr_example("logistic", method = "optimize")
fit_logistic_optim$summary()
fit_logistic_vb <- cmdstanr_example("logistic", method = "variational")
fit_logistic_vb$summary()
print_example_program("schools")
fit_schools_mcmc <- cmdstanr_example("schools")
fit_schools_mcmc$summary()
print_example_program("schools_ncp")
fit_schools_ncp_mcmc <- cmdstanr_example("schools_ncp")
fit_schools_ncp_mcmc$summary()
# optimization fails for hierarchical model
cmdstanr_example("schools", "optimize", quiet = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.