Skip to content

Commit 23e76b2

Browse files
committed
ppc_loo_pit_qq(): On the y axis, use standard normal quantiles calculated from the PIT values instead of standardized PIT values.
1 parent 5500d2e commit 23e76b2

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

R/ppc-loo.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@
4242
#' PITs to the standard uniform distribution. Comparing to the uniform is not
4343
#' good for extreme probabilities close to 0 and 1, so it can sometimes be
4444
#' useful to set the `compare` argument to `"normal"`, which will
45-
#' produce a Q-Q plot comparing standardized PIT values to the standard normal
46-
#' distribution that can help see the (mis)calibration better for the extreme
47-
#' values. However, in most cases we have found that the overlaid density plot
48-
#' (`ppc_loo_pit_overlay()`) function will provided a clearer picture of
49-
#' calibration problems that the Q-Q plot.
45+
#' produce a Q-Q plot comparing standard normal quantiles calculated from the
46+
#' PIT values to the theoretical standard normal quantiles. This can help see
47+
#' the (mis)calibration better for the extreme values. However, in most cases
48+
#' we have found that the overlaid density plot (`ppc_loo_pit_overlay()`)
49+
#' function will provide a clearer picture of calibration problems than the
50+
#' Q-Q plot.
5051
#' }
5152
#' \item{`ppc_loo_intervals()`, `ppc_loo_ribbon()`}{
5253
#' Similar to [ppc_intervals()] and [ppc_ribbon()] but the intervals are for
@@ -113,8 +114,9 @@ NULL
113114
#' @param compare For `ppc_loo_pit_qq()`, a string that can be either
114115
#' `"uniform"` or `"normal"`. If `"uniform"` (the default) the Q-Q plot
115116
#' compares computed PIT values to the standard uniform distribution. If
116-
#' `compare="normal"`, the Q-Q plot compares standardized PIT values to the
117-
#' standard normal distribution.
117+
#' `compare="normal"`, the Q-Q plot compares standard normal quantiles
118+
#' calculated from the PIT values to the theoretical standard normal
119+
#' quantiles.
118120
#' @param trim Passed to [ggplot2::stat_density()].
119121
#' @template args-density-controls
120122
ppc_loo_pit_overlay <- function(y,
@@ -220,10 +222,10 @@ ppc_loo_pit_qq <- function(y,
220222
x_lab <- "Uniform"
221223
y_lab <- "LOO-PIT"
222224
} else {
223-
pit <- as.vector(scale(pit))
225+
pit <- as.vector(stats::qnorm(pit))
224226
theoretical <- stats::qnorm
225227
x_lab <- "Normal"
226-
y_lab <- "LOO-PIT (standardized)"
228+
y_lab <- "LOO-PIT (standard normal quantiles)"
227229
}
228230

229231
ggplot(data.frame(p = pit)) +

0 commit comments

Comments
 (0)