@@ -1497,10 +1497,10 @@ CmdStanMCMC <- R6::R6Class(
14971497# ' and the \pkg{loo} package [vignettes](https://mc-stan.org/loo/articles/)
14981498# ' for details.
14991499# '
1500- # ' @param variables (character vector ) The name(s) of the variable(s) in the
1501- # ' Stan program containing the pointwise log-likelihood. The default is to
1502- # ' look for `"log_lik"`. This argument is passed to the
1503- # ' [`$draws()`][fit-method-draws] method.
1500+ # ' @param variables (string ) The name of the variable in the Stan program
1501+ # ' containing the pointwise log-likelihood. The default is to look for
1502+ # ' `"log_lik"`. This argument is passed to the [`$draws()`][fit-method-draws]
1503+ # ' method.
15041504# ' @param r_eff (multiple options) How to handle the `r_eff` argument for `loo()`:
15051505# ' * `TRUE` (the default) will automatically call [loo::relative_eff.array()]
15061506# ' to compute the `r_eff` argument to pass to [loo::loo.array()].
@@ -1539,6 +1539,9 @@ CmdStanMCMC <- R6::R6Class(
15391539# '
15401540loo <- function (variables = " log_lik" , r_eff = TRUE , moment_match = FALSE , ... ) {
15411541 require_suggested_package(" loo" )
1542+ if (length(variables ) != 1 ) {
1543+ stop(" Only a single variable name is allowed for the 'variables' argument." , call. = FALSE )
1544+ }
15421545 LLarray <- self $ draws(variables , format = " draws_array" )
15431546 if (is.logical(r_eff )) {
15441547 if (isTRUE(r_eff )) {
@@ -1806,6 +1809,11 @@ CmdStanMCMC$set("public", name = "num_chains", value = num_chains)
18061809# '
18071810# ' @description A `CmdStanMLE` object is the fitted model object returned by the
18081811# ' [`$optimize()`][model-method-optimize] method of a [`CmdStanModel`] object.
1812+ # ' This object will either contain a penalized maximum likelihood estimate
1813+ # ' (MLE) or a maximum a posteriori estimate (MAP), depending on the value of
1814+ # ' the `jacobian` argument when the model is fit (and whether the model has
1815+ # ' constrained parameters). See [`$optimize()`][model-method-optimize] and the
1816+ # ' CmdStan User's Guide for more details.
18091817# '
18101818# ' @section Methods: `CmdStanMLE` objects have the following associated methods,
18111819# ' all of which have their own (linked) documentation pages.
@@ -1875,17 +1883,22 @@ CmdStanMLE <- R6::R6Class(
18751883 )
18761884)
18771885
1878- # ' Extract (penalized) maximum likelihood estimate after optimization
1886+ # ' Extract point estimate after optimization
18791887# '
18801888# ' @name fit-method-mle
18811889# ' @aliases mle
1882- # ' @description The `$mle()` method is only available for [`CmdStanMLE`] objects.
1883- # ' It returns the penalized maximum likelihood estimate (posterior mode) as a
1884- # ' numeric vector with one element per variable. The returned vector does *not*
1885- # ' include `lp__`, the total log probability (`target`) accumulated in the
1886- # ' model block of the Stan program, which is available via the
1887- # ' [`$lp()`][fit-method-lp] method and also included in the
1888- # ' [`$draws()`][fit-method-draws] method.
1890+ # ' @description The `$mle()` method is only available for [`CmdStanMLE`]
1891+ # ' objects. It returns the point estimate as a numeric vector with one element
1892+ # ' per variable. The returned vector does *not* include `lp__`, the total log
1893+ # ' probability (`target`) accumulated in the model block of the Stan program,
1894+ # ' which is available via the [`$lp()`][fit-method-lp] method and also
1895+ # ' included in the [`$draws()`][fit-method-draws] method.
1896+ # '
1897+ # ' For models with constrained parameters that are fit with `jacobian=TRUE`,
1898+ # ' the `$mle()` method actually returns the maximum a posteriori (MAP)
1899+ # ' estimate (posterior mode) rather than the MLE. See
1900+ # ' [`$optimize()`][model-method-optimize] and the CmdStan User's Guide for
1901+ # ' more details.
18891902# '
18901903# ' @param variables (character vector) The variables (parameters, transformed
18911904# ' parameters, and generated quantities) to include. If NULL (the default)
@@ -1910,6 +1923,7 @@ mle <- function(variables = NULL) {
19101923}
19111924CmdStanMLE $ set(" public" , name = " mle" , value = mle )
19121925
1926+
19131927# CmdStanLaplace ---------------------------------------------------------------
19141928# ' CmdStanLaplace objects
19151929# '
0 commit comments