Skip to content

Commit 582e18d

Browse files
authored
Merge pull request #173 from stan-dev/fix-loo_compare-doc
mention how to specify names in loo_compare doc
2 parents ca3e225 + 6cc4893 commit 582e18d

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

R/E_loo.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#'
5252
#' @examples
5353
#' \donttest{
54+
#' if (requireNamespace("rstanarm", quietly = TRUE)) {
5455
#' # Use rstanarm package to quickly fit a model and get both a log-likelihood
5556
#' # matrix and draws from the posterior predictive distribution
5657
#' library("rstanarm")
@@ -81,6 +82,7 @@
8182
#' # log-likelihood values using the log_ratios argument.
8283
#' E_loo(yrep, psis_object, type = "mean", log_ratios = log_ratios)
8384
#' }
85+
#' }
8486
#'
8587
E_loo <- function(x, psis_object, ...) {
8688
UseMethod("E_loo")

R/loo_compare.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
#' `print(..., simplify=FALSE)` to print a more detailed summary.
77
#'
88
#' @export
9-
#' @param x An object of class `"loo"` or a list of such objects.
10-
#' @param ... Additional objects of class `"loo"`.
9+
#' @param x An object of class `"loo"` or a list of such objects. If a list is
10+
#' used then the list names will be used as the model names in the output. See
11+
#' **Examples**.
12+
#' @param ... Additional objects of class `"loo"`, if not passed in as a single
13+
#' list.
1114
#'
1215
#' @return A matrix with class `"compare.loo"` that has its own
1316
#' print method. See the **Details** section.
@@ -55,8 +58,9 @@
5558
#' # (will be the same for all models in this artificial example)
5659
#' print(comp, simplify = FALSE, digits = 3)
5760
#'
58-
#' # can use a list of objects
59-
#' loo_compare(x = list(loo1, loo2, loo3))
61+
#' # can use a list of objects with custom names
62+
#' # will use apple, banana, and cherry, as the names in the output
63+
#' loo_compare(list("apple" = loo1, "banana" = loo2, "cherry" = loo3))
6064
#'
6165
#' \dontrun{
6266
#' # works for waic (and kfold) too

man/E_loo.Rd

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

man/loo_compare.Rd

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

0 commit comments

Comments
 (0)