@@ -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,6 +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()`.
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
1375+ # ' [Maximum Likelihood Estimation](https://mc-stan.org/docs/cmdstan-guide/maximum-likelihood-estimation.html)
1376+ # ' section of the CmdStan User's Guide for more details.
13771377# ' @param init_alpha (positive real) The initial step size parameter.
13781378# ' @param tol_obj (positive real) Convergence tolerance on changes in objective function value.
13791379# ' @param tol_rel_obj (positive real) Convergence tolerance on relative changes in objective function value.
@@ -1399,6 +1399,7 @@ optimize <- function(data = NULL,
13991399 threads = NULL ,
14001400 opencl_ids = NULL ,
14011401 algorithm = NULL ,
1402+ jacobian = FALSE ,
14021403 init_alpha = NULL ,
14031404 iter = NULL ,
14041405 tol_obj = NULL ,
@@ -1418,6 +1419,7 @@ optimize <- function(data = NULL,
14181419 }
14191420 optimize_args <- OptimizeArgs $ new(
14201421 algorithm = algorithm ,
1422+ jacobian = jacobian ,
14211423 init_alpha = init_alpha ,
14221424 iter = iter ,
14231425 tol_obj = tol_obj ,
0 commit comments