Skip to content

Commit 7c7b5d2

Browse files
authored
Merge pull request #1115 from stan-dev/fix-optimize-doc
fix optimize doc Jacobian description
2 parents d7d3999 + c59b5b9 commit 7c7b5d2

File tree

5 files changed

+52
-42
lines changed

5 files changed

+52
-42
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ URL: https://mc-stan.org/cmdstanr/, https://discourse.mc-stan.org
3232
BugReports: https://github.com/stan-dev/cmdstanr/issues
3333
Encoding: UTF-8
3434
LazyData: true
35-
RoxygenNote: 7.3.2
35+
RoxygenNote: 7.3.3
3636
Roxygen: list(markdown = TRUE, r6 = FALSE)
3737
SystemRequirements: CmdStan (https://mc-stan.org/users/interfaces/cmdstan)
3838
Depends:

R/fit.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,11 +1812,13 @@ CmdStanMCMC$set("public", name = "num_chains", value = num_chains)
18121812
#'
18131813
#' @description A `CmdStanMLE` object is the fitted model object returned by the
18141814
#' [`$optimize()`][model-method-optimize] method of a [`CmdStanModel`] object.
1815-
#' This object will either contain a penalized maximum likelihood estimate
1816-
#' (MLE) or a maximum a posteriori estimate (MAP), depending on the value of
1817-
#' the `jacobian` argument when the model is fit (and whether the model has
1818-
#' constrained parameters). See [`$optimize()`][model-method-optimize] and the
1819-
#' CmdStan User's Guide for more details.
1815+
#' The name "MLE" (used for historical reasons) is a bit misleading since this
1816+
#' object will contain parameter estimates corresponding to either a mode in
1817+
#' the constrained parameter space _or_ the unconstrained parameter space,
1818+
#' depending on the value of the `jacobian` argument when the model is fit
1819+
#' (and whether the model has constrained parameters). See
1820+
#' [`$optimize()`][model-method-optimize] and the CmdStan User's Guide for
1821+
#' more details.
18201822
#'
18211823
#' @section Methods: `CmdStanMLE` objects have the following associated methods,
18221824
#' all of which have their own (linked) documentation pages.

R/model.R

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,14 +1447,18 @@ CmdStanModel$set("public", name = "sample_mpi", value = sample_mpi)
14471447
#' @family CmdStanModel methods
14481448
#'
14491449
#' @description The `$optimize()` method of a [`CmdStanModel`] object runs
1450-
#' Stan's optimizer to obtain a (penalized) maximum likelihood estimate (MLE)
1451-
#' or a maximum a posteriori estimate (MAP), depending on the value of the
1452-
#' `jacobian` argument. For models with constrained parameters, when the
1453-
#' Jacobian adjustment is *not* applied, the point estimate corresponds to a
1454-
#' penalized MLE, and when the Jacobian adjustment is applied the point
1455-
#' estimate corresponds to the MAP (posterior mode) of the model we would fit
1456-
#' if we were instead doing MCMC sampling. The Jacobian adjustment has no
1457-
#' affect if the model has only unconstrained parameters. See the
1450+
#' Stan's optimizer to find a posterior mode. If the Jacobian adjustment is
1451+
#' not included (the default), the optimization returns parameter values that
1452+
#' correspond to a mode of the target in the constrained space (if such mode
1453+
#' exists). Thus this option is useful for any optimization where we want to
1454+
#' find the mode in the original constrained parameter space. If the Jacobian
1455+
#' adjustment is included, the optimization returns parameter values that
1456+
#' correspond to a mode in the unconstrained space. This is useful, for
1457+
#' example, if we want to make a distributional approximation of the posterior
1458+
#' at the mode (see, [Laplace sampling][model-method-laplace], for which the
1459+
#' Jacobian adjustment needs to be included for correct results). If the model
1460+
#' has only unconstrained parameters, there is no effect from including the
1461+
#' Jacobian. See the
14581462
#' [CmdStan User's Guide](https://mc-stan.org/docs/cmdstan-guide/index.html)
14591463
#' for more details.
14601464
#'
@@ -1477,13 +1481,12 @@ CmdStanModel$set("public", name = "sample_mpi", value = sample_mpi)
14771481
#' the CmdStan User's Guide. The default values can also be obtained by
14781482
#' running `cmdstanr_example(method="optimize")$metadata()`.
14791483
#' @param jacobian (logical) Whether or not to use the Jacobian adjustment for
1480-
#' constrained variables. For historical reasons, the default is `FALSE`, meaning optimization
1481-
#' yields the (regularized) maximum likelihood estimate. Setting it to `TRUE`
1482-
#' yields the maximum a posteriori estimate. See the
1483-
#' [Maximum Likelihood Estimation](https://mc-stan.org/docs/cmdstan-guide/maximum-likelihood-estimation.html)
1484-
#' section of the CmdStan User's Guide for more details.
1485-
#' For use later with [`$laplace()`][model-method-laplace] the `jacobian`
1486-
#' argument should typically be set to `TRUE`.
1484+
#' constrained variables. For historical reasons, the default is `FALSE`,
1485+
#' meaning optimization finds a mode of the target in the original constrained
1486+
#' parameter space. Setting it to `TRUE` finds a mode in the unconstrained
1487+
#' space. See the CmdStan User's Guide for more details. For use later with
1488+
#' [`$laplace()`][model-method-laplace] the `jacobian` argument should
1489+
#' typically be set to `TRUE`.
14871490
#' @param init_alpha (positive real) The initial step size parameter.
14881491
#' @param tol_obj (positive real) Convergence tolerance on changes in objective function value.
14891492
#' @param tol_rel_obj (positive real) Convergence tolerance on relative changes in objective function value.
@@ -2372,4 +2375,4 @@ resolve_exe_path <- function(
23722375
exe <- self_exe_file
23732376
}
23742377
exe
2375-
}
2378+
}

man/CmdStanMLE.Rd

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

man/model-method-optimize.Rd

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

0 commit comments

Comments
 (0)