Skip to content

Commit 18e92f9

Browse files
committed
Merge branch 'master' into laplace-sample
2 parents 3c3a333 + 2ebf195 commit 18e92f9

23 files changed

Lines changed: 272 additions & 160 deletions

R/example.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#' the individual methods for details.
2020
#' @param quiet (logical) If `TRUE` (the default) then fitting the model is
2121
#' wrapped in [utils::capture.output()].
22+
#' @param force_recompile Passed to the [$compile()][model-method-compile] method.
2223
#'
2324
#' @return
2425
#' The fitted model object returned by the selected `method`.
@@ -51,7 +52,8 @@ cmdstanr_example <-
5152
function(example = c("logistic", "schools", "schools_ncp"),
5253
method = c("sample", "optimize", "laplace", "variational", "diagnose"),
5354
...,
54-
quiet = TRUE) {
55+
quiet = TRUE,
56+
force_recompile = getOption("cmdstanr_force_recompile", default = FALSE)) {
5557

5658
example <- match.arg(example)
5759
method <- match.arg(method)
@@ -63,7 +65,7 @@ cmdstanr_example <-
6365
if (!file.exists(tmp)) {
6466
file.copy(system.file(example_program, package = "cmdstanr"), tmp)
6567
}
66-
mod <- cmdstan_model(tmp)
68+
mod <- cmdstan_model(tmp, force_recompile = force_recompile)
6769
data_file <- system.file(example_data, package = "cmdstanr")
6870

6971
if (quiet) {

R/fit.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ CmdStanFit$set("public", name = "init", value = init)
325325
#'
326326
#' @examples
327327
#' \dontrun{
328-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
328+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
329329
#' fit_mcmc$init_model_methods()
330330
#' }
331331
#' @seealso [log_prob()], [grad_log_prob()], [constrain_variables()],
@@ -371,7 +371,7 @@ CmdStanFit$set("public", name = "init_model_methods", value = init_model_methods
371371
#'
372372
#' @examples
373373
#' \dontrun{
374-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
374+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
375375
#' fit_mcmc$init_model_methods()
376376
#' fit_mcmc$log_prob(unconstrained_variables = c(0.5, 1.2, 1.1, 2.2))
377377
#' }
@@ -409,7 +409,7 @@ CmdStanFit$set("public", name = "log_prob", value = log_prob)
409409
#'
410410
#' @examples
411411
#' \dontrun{
412-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
412+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
413413
#' fit_mcmc$init_model_methods()
414414
#' fit_mcmc$grad_log_prob(unconstrained_variables = c(0.5, 1.2, 1.1, 2.2))
415415
#' }
@@ -447,7 +447,7 @@ CmdStanFit$set("public", name = "grad_log_prob", value = grad_log_prob)
447447
#'
448448
#' @examples
449449
#' \dontrun{
450-
#' # fit_mcmc <- cmdstanr_example("logistic", method = "sample")
450+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
451451
#' # fit_mcmc$init_model_methods(hessian = TRUE)
452452
#' # fit_mcmc$hessian(unconstrained_variables = c(0.5, 1.2, 1.1, 2.2))
453453
#' }
@@ -482,7 +482,7 @@ CmdStanFit$set("public", name = "hessian", value = hessian)
482482
#'
483483
#' @examples
484484
#' \dontrun{
485-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
485+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
486486
#' fit_mcmc$init_model_methods()
487487
#' fit_mcmc$unconstrain_variables(list(alpha = 0.5, beta = c(0.7, 1.1, 0.2)))
488488
#' }
@@ -540,7 +540,7 @@ CmdStanFit$set("public", name = "unconstrain_variables", value = unconstrain_var
540540
#'
541541
#' @examples
542542
#' \dontrun{
543-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
543+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
544544
#' fit_mcmc$init_model_methods()
545545
#'
546546
#' # Unconstrain all internal draws
@@ -619,7 +619,7 @@ CmdStanFit$set("public", name = "unconstrain_draws", value = unconstrain_draws)
619619
#'
620620
#' @examples
621621
#' \dontrun{
622-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
622+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
623623
#' fit_mcmc$init_model_methods()
624624
#' fit_mcmc$variable_skeleton()
625625
#' }
@@ -657,7 +657,7 @@ CmdStanFit$set("public", name = "variable_skeleton", value = variable_skeleton)
657657
#'
658658
#' @examples
659659
#' \dontrun{
660-
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample")
660+
#' fit_mcmc <- cmdstanr_example("logistic", method = "sample", force_recompile = TRUE)
661661
#' fit_mcmc$init_model_methods()
662662
#' fit_mcmc$constrain_variables(unconstrained_variables = c(0.5, 1.2, 1.1, 2.2))
663663
#' }

R/model.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ compile <- function(quiet = TRUE,
604604
wd = cmdstan_path(),
605605
echo = !quiet || is_verbose_mode(),
606606
echo_cmd = is_verbose_mode(),
607-
spinner = quiet && interactive(),
607+
spinner = quiet && interactive() && !identical(Sys.getenv("IN_PKGDOWN"), "true"),
608608
stderr_callback = function(x, p) {
609609
if (!startsWith(x, paste0(make_cmd(), ": *** No rule to make target"))) {
610610
message(x)

docs/reference/Rplot001.png

-3.93 KB
Loading

docs/reference/cmdstanr_example.html

Lines changed: 87 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/fit-method-constrain_variables.html

Lines changed: 37 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)