|
49 | 49 | #' |
50 | 50 | #' * `N < 100` (small data) |
51 | 51 | #' * `|elpd_diff| < 4` (models make similar predictions) |
52 | | -#' * `k_diff > 0.5` (possible outliers) |
53 | 52 | #' |
54 | | -#' If any of these diagnostic messages is shown, the error distribution is |
| 53 | +#' If either of these diagnostic messages is shown, the error distribution is |
55 | 54 | #' skewed or thick tailed and the normal approximation based on `elpd_diff` |
56 | 55 | #' and `se_diff` is not well calibrated. In that case, the probabilities |
57 | | -#' `p_worse` are likely to be too large (small data or similar predictions) or |
58 | | -#' too small (outliers). However, `elpd_diff` and `se_diff` will still be |
59 | | -#' indicative of the differences and uncertainties (for example, if |
60 | | -#' `|elpd_diff|` is many times larger than `se_diff` the difference is quite |
61 | | -#' certain). |
62 | | -#' |
63 | | -#' The `k_diff` value for the `diag_diff` column is computed using the |
64 | | -#' pointwise ELPD differences (and is different from the Pareto k's in |
65 | | -#' PSIS-LOO diagnostic). While `k_diff > 0.5` indicates the *possibility* of |
66 | | -#' outliers, it is also possible that both models compared seem to be well |
67 | | -#' specified based on model checking, but the pointwise ELPD differences have |
68 | | -#' such thick tails that the normal approximation for the sum is not good |
69 | | -#' (Vehtari et al., 2024). A threshold of 0.5 is used for `k_diff` as we do |
70 | | -#' not do automatic Pareto smoothing for the pointwise differences (Vehtari et |
71 | | -#' al., 2024). |
| 56 | +#' `p_worse` are likely to be too large. However, `elpd_diff` and `se_diff` |
| 57 | +#' will still be indicative of the differences and uncertainties (for example, |
| 58 | +#' if `|elpd_diff|` is many times larger than `se_diff` the difference is quite |
| 59 | +#' certain). In addition, if the model is not well specificed and there are |
| 60 | +#' outliers, the error distribution can also be skewed or thick tailed and the |
| 61 | +#' normal approximation is not well calibrated. Possible model misspecification |
| 62 | +#' and outliers can be diagnosed with usual predictive checking methods. |
72 | 63 | #' |
73 | 64 | #' The column `diag_elpd` shows the PSIS-LOO Pareto k diagnostic for the |
74 | 65 | #' pointwise ELPD computations for each model. If `K k_psis > 0.7` is shown, |
@@ -433,12 +424,6 @@ diag_diff <- function(N, elpd_diff) { |
433 | 424 | } else { |
434 | 425 | diag_diff <- rep("", length(elpd_diff)) |
435 | 426 | diag_diff[elpd_diff > -4 & elpd_diff != 0] <- "|elpd_diff| < 4" |
436 | | - k_diff <- rep(NA, length(elpd_diff)) |
437 | | - k_diff[elpd_diff != 0] <- apply( |
438 | | - diffs[, elpd_diff != 0, drop = FALSE], 2, |
439 | | - function(x) ifelse(length(unique(x)) <= 20, NA, posterior::pareto_khat(x, tail = "both") |
440 | | - )) |
441 | | - diag_diff[k_diff > 0.5] <- "k_diff > 0.5" |
442 | 427 | } |
443 | 428 | diag_diff |
444 | 429 | } |
0 commit comments