Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion R/loo_compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
#' comp <- loo_compare(loo1, loo2, loo3)
#' print(comp, digits = 2)
#'
#' # print full table with pointwise ELPD and LOOIC
#' print(comp, simplify = FALSE)
#'
#' # can use a list of objects with custom names
#' # the names will be used in the output
#' loo_compare(list("apple" = loo1, "banana" = loo2, "cherry" = loo3))
Expand Down Expand Up @@ -170,7 +173,11 @@ loo_compare.default <- function(x, ...) {
#' @param p_worse For the print method only, should we include the normal
#' approximation based probability of each model having worse performance than
#' the best model? The default is `TRUE`.
print.compare.loo <- function(x, ..., digits = 1, p_worse = TRUE) {
#' @param simplify For the print method only, should the output be simplified
#' to only include the model names and ELPD differences? The default is
#' `TRUE`. If `FALSE`, the full comparison table is printed including
#' pointwise ELPD, LOOIC/WAIC, and their standard errors for each model.
print.compare.loo <- function(x, ..., digits = 1, p_worse = TRUE, simplify = TRUE) {
if (inherits(x, "old_compare.loo")) {
return(unclass(x))
}
Expand All @@ -193,6 +200,16 @@ print.compare.loo <- function(x, ..., digits = 1, p_worse = TRUE) {
diag_elpd = x[, "diag_elpd"]
)
}
if (!simplify) {
est_cols <- c("elpd_loo", "se_elpd_loo", "p_loo", "se_p_loo",
"looic", "se_looic",
"elpd_waic", "se_elpd_waic", "p_waic", "se_p_waic",
"waic", "se_waic")
avail <- intersect(est_cols, colnames(x))
if (length(avail)) {
x2 <- cbind(x2, .fr(x[, avail], digits))
}
}
print(x2, quote = FALSE, row.names = FALSE)

# show glossary for diagnostic flags
Expand Down
4 changes: 2 additions & 2 deletions man/loo-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/loo_compare.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading