Skip to content

Commit 89d39f5

Browse files
committed
change diag_pnorm to diag_diff
1 parent 23a79c0 commit 89d39f5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

R/loo_compare.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
#' distribution, a practice derived for Gaussian linear models or
4040
#' asymptotically, and which only applies to nested models in any case.
4141
#'
42-
#' ## `p_worse` and `diag_pnorm`
42+
#' ## `p_worse` and `diag_diff`
4343
#' The values in the `p_worse` column show the probability of each model
4444
#' having worse ELPD than the best model. These probabilities are computed
4545
#' with a normal approximation using the values from `elpd_diff` and
4646
#' `se_diff`. Sivula et al. (2025) present the conditions when the normal
4747
#' approximation used for SE and `se_diff` is good, and the column
48-
#' `diag_pnorm` contains possible diagnostic messages:
48+
#' `diag_diff` contains possible diagnostic messages:
4949
#'
5050
#' * `N < 100` (small data)
5151
#' * `|elpd_diff| < 4` (models make similar predictions)
@@ -137,24 +137,24 @@ loo_compare.default <- function(x, ...) {
137137
# * khat_diff > 0.5: possible outliers in differences (Sivula et al., 2025; Vehtari et al., 2024)
138138
N <- nrow(diffs)
139139
if (N < 100) {
140-
diag_pnorm <- rep("N < 100", length(elpd_diff))
141-
diag_pnorm[elpd_diff == 0] <- ""
140+
diag_diff <- rep("N < 100", length(elpd_diff))
141+
diag_diff[elpd_diff == 0] <- ""
142142
} else {
143-
diag_pnorm <- rep("", length(elpd_diff))
144-
diag_pnorm[elpd_diff > -4 & elpd_diff != 0] <- "|elpd_diff| < 4"
143+
diag_diff <- rep("", length(elpd_diff))
144+
diag_diff[elpd_diff > -4 & elpd_diff != 0] <- "|elpd_diff| < 4"
145145
khat_diff <- rep(NA, length(elpd_diff))
146146
khat_diff[elpd_diff != 0] <- apply(
147147
diffs[, elpd_diff != 0, drop = FALSE], 2,
148148
function(x) ifelse(length(unique(x)) <= 20, NA, posterior::pareto_khat(x, tail = "both")
149149
))
150-
diag_pnorm[khat_diff > 0.5] <- "khat_diff > 0.5"
150+
diag_diff[khat_diff > 0.5] <- "khat_diff > 0.5"
151151
}
152152
comp <- cbind(
153153
data.frame(
154154
elpd_diff = elpd_diff,
155155
se_diff = se_diff,
156156
p_worse = p_worse,
157-
diag_pnorm = diag_pnorm
157+
diag_diff = diag_diff
158158
),
159159
as.data.frame(comp)
160160
)
@@ -188,7 +188,7 @@ print.compare.loo <- function(x, ..., digits = 1, p_worse = TRUE) {
188188
print(
189189
cbind(.fr(xcopy, digits),
190190
p_worse = .fr(x[, "p_worse"], 2),
191-
diag_pnorm = x[, "diag_pnorm"]),
191+
diag_diff = x[, "diag_diff"]),
192192
quote = FALSE
193193
)
194194
} else {

0 commit comments

Comments
 (0)