Skip to content

Commit 6fe41bb

Browse files
avehtarijgabry
andauthored
Apply Jonah's suggestions from code review
Co-authored-by: Jonah Gabry <[email protected]>
1 parent b940192 commit 6fe41bb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

R/loo_compare.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ loo_compare.default <- function(x, ...) {
118118
se_diff <- apply(diffs, 2, se_elpd_diff)
119119
# compute probabilities that a model has worse elpd than the best model
120120
# using a normal approximation (Sivula et al., 2025)
121-
p_worse <- pnorm(0, elpd_diff, se_diff)
121+
p_worse <- stats::pnorm(0, elpd_diff, se_diff)
122122
p_worse[elpd_diff==0] <- NA
123123
N <- nrow(diffs)
124124
# diagnostics to assess whether the normal approximation can be trusted
@@ -154,9 +154,11 @@ loo_compare.default <- function(x, ...) {
154154
#' @param digits For the print method only, the number of digits to use when
155155
#' printing.
156156
#' @param simplify For the print method only, should only the essential columns
157-
#' of the summary matrix be printed? The entire matrix is always returned, bu#' @param pnorm For the print method only, should we include the normal
158-
#' approximation based probability of model having worse performance than
159-
#' the best model
157+
#' of the summary matrix be printed? The entire matrix is always returned, but
158+
#' by default only the most important columns are printed.
159+
#' @param pnorm For the print method only, should we include the normal
160+
#' approximation based probability of each model having worse performance than
161+
#' the best model?
160162
print.compare.loo <- function(x, ..., digits = 1, simplify = TRUE, pnorm = FALSE) {
161163
xcopy <- x
162164
if (inherits(xcopy, "old_compare.loo")) {
@@ -171,7 +173,7 @@ print.compare.loo <- function(x, ..., digits = 1, simplify = TRUE, pnorm = FALSE
171173
print(cbind(.fr(xcopy, digits), p_worse=.fr(x[,"p_worse"],2), diag_pnorm=x[, "diag_pnorm"]), quote = FALSE)
172174
invisible(x)
173175
} else {
174-
print(cbind(.fr(xcopy, digits), quote = FALSE))
176+
print(cbind(.fr(xcopy, digits)), quote = FALSE)
175177
invisible(x)
176178
}
177179
}

0 commit comments

Comments
 (0)