Skip to content

Commit b47a327

Browse files
committed
default jacobian=FALSE and improve doc
1 parent c998ace commit b47a327

File tree

2 files changed

+29
-46
lines changed

2 files changed

+29
-46
lines changed

R/model.R

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,23 +1346,17 @@ CmdStanModel$set("public", name = "sample_mpi", value = sample_mpi)
13461346
#' @family CmdStanModel methods
13471347
#'
13481348
#' @description The `$optimize()` method of a [`CmdStanModel`] object runs
1349-
#' Stan's optimizer to obtain a posterior mode (penalized maximum likelihood)
1350-
#' estimate.
1349+
#' Stan's optimizer to obtain a (penalized) maximum likelihood estimate or a
1350+
#' maximum a posteriori estimate (if `jacobian=TRUE`). See the
1351+
#' [Maximum Likelihood Estimation](https://mc-stan.org/docs/cmdstan-guide/maximum-likelihood-estimation.html)
1352+
#' section of the CmdStan User's Guide for more details.
13511353
#'
13521354
#' Any argument left as `NULL` will default to the default value used by the
1353-
#' installed version of CmdStan. See the
1354-
#' [CmdStan User’s Guide](https://mc-stan.org/docs/cmdstan-guide/)
1355-
#' for more details.
1356-
#'
1357-
#' @details CmdStan can find the posterior mode (assuming there is one). If the
1358-
#' posterior is not convex, there is no guarantee Stan will be able to find
1359-
#' the global mode as opposed to a local optimum of log probability. For
1360-
#' optimization, the mode is calculated without the Jacobian adjustment for
1361-
#' constrained variables, which shifts the mode due to the change of
1362-
#' variables. Thus modes correspond to modes of the model as written.
1363-
#'
1364-
#' -- [*CmdStan User's Guide*](https://mc-stan.org/docs/cmdstan-guide/)
1365-
#'
1355+
#' installed version of CmdStan. See the [CmdStan User’s
1356+
#' Guide](https://mc-stan.org/docs/cmdstan-guide/) for more details on the
1357+
#' default arguments. The default values can also be obtained by checking the
1358+
#' metadata of an example model, e.g.,
1359+
#' `cmdstanr_example(method="optimize")$metadata()`.
13661360
#' @template model-common-args
13671361
#' @param threads (positive integer) If the model was
13681362
#' [compiled][model-method-compile] with threading support, the number of
@@ -1374,14 +1368,12 @@ CmdStanModel$set("public", name = "sample_mpi", value = sample_mpi)
13741368
#' for `"lbfgs"` and `"bfgs`. For their default values and more details see
13751369
#' the CmdStan User's Guide. The default values can also be obtained by
13761370
#' running `cmdstanr_example(method="optimize")$metadata()`.
1377-
#' @param jacobian (logical) Whether or not the model’s log probability
1378-
#' function should include the log absolute Jacobian determinant of inverse
1379-
#' parameter transforms. If `jacobian=FALSE` (historically this has always
1380-
#' been the default) optimization returns the regularized maximum likelihood
1381-
#' estimate (MLE). If `jacobian=TRUE` optimization produces the maximum a
1382-
#' posteriori estimate (MAP). See the
1371+
#' @param jacobian (logical) Whether or not to use the Jacobian adjustment for
1372+
#' constrained variables. By default this is `FALSE`, meaning optimization
1373+
#' yields the (regularized) maximum likelihood estimate. Setting it to `TRUE`
1374+
#' yields the maximum a posteriori estimate. See the
13831375
#' [Maximum Likelihood Estimation](https://mc-stan.org/docs/cmdstan-guide/maximum-likelihood-estimation.html)
1384-
#' section of the CmdStan User's Guide for more details on the Jacobian adjustments.
1376+
#' section of the CmdStan User's Guide for more details.
13851377
#' @param init_alpha (positive real) The initial step size parameter.
13861378
#' @param tol_obj (positive real) Convergence tolerance on changes in objective function value.
13871379
#' @param tol_rel_obj (positive real) Convergence tolerance on relative changes in objective function value.
@@ -1407,7 +1399,7 @@ optimize <- function(data = NULL,
14071399
threads = NULL,
14081400
opencl_ids = NULL,
14091401
algorithm = NULL,
1410-
jacobian = NULL,
1402+
jacobian = FALSE,
14111403
init_alpha = NULL,
14121404
iter = NULL,
14131405
tol_obj = NULL,

man/model-method-optimize.Rd

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

0 commit comments

Comments
 (0)