diff --git a/R/loo_compare.R b/R/loo_compare.R index ce5bea4a..80202507 100644 --- a/R/loo_compare.R +++ b/R/loo_compare.R @@ -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)) @@ -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)) } @@ -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 diff --git a/man/loo-package.Rd b/man/loo-package.Rd index aa158231..840b0594 100644 --- a/man/loo-package.Rd +++ b/man/loo-package.Rd @@ -124,9 +124,9 @@ Authors: \itemize{ \item Jonah Gabry \email{jgabry@gmail.com} \item Aki Vehtari \email{Aki.Vehtari@aalto.fi} - \item Måns Magnusson + \item Mns Magnusson \item Yuling Yao - \item Paul-Christian Bürkner + \item Paul-Christian Brkner \item Topi Paananen \item Andrew Gelman } diff --git a/man/loo_compare.Rd b/man/loo_compare.Rd index c54b9f86..361b52c2 100644 --- a/man/loo_compare.Rd +++ b/man/loo_compare.Rd @@ -12,7 +12,7 @@ loo_compare(x, ...) \method{loo_compare}{default}(x, ...) -\method{print}{compare.loo}(x, ..., digits = 1, p_worse = TRUE) +\method{print}{compare.loo}(x, ..., digits = 1, p_worse = TRUE, simplify = TRUE) \method{print}{compare.loo_ss}(x, ..., digits = 1) } @@ -30,6 +30,11 @@ printing.} \item{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 \code{TRUE}.} + +\item{simplify}{For the print method only, should the output be simplified +to only include the model names and ELPD differences? The default is +\code{TRUE}. If \code{FALSE}, the full comparison table is printed including +pointwise ELPD, LOOIC/WAIC, and their standard errors for each model.} } \value{ A data frame with class \code{"compare.loo"} that has its own @@ -119,6 +124,9 @@ loo3 <- loo(LL + 2) # should be best model when compared 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))