Skip to content

Commit 14f9833

Browse files
authored
Merge pull request #307 from stan-dev/fix-ppc_loo_pit_qq
better loo_pit_qq plots
2 parents d9c8f41 + 6cb9ce7 commit 14f9833

File tree

2 files changed

+129
-133
lines changed

2 files changed

+129
-133
lines changed

R/ppc-loo.R

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ ppc_loo_pit_overlay <- function(y,
189189
geom_line(
190190
aes(color = "y"),
191191
data = function(x) dplyr::filter(x, .data$is_y),
192-
linewidth = 1,
192+
linewidth = 1,
193193
lineend = "round",
194194
na.rm = TRUE) +
195195
scale_x_continuous(
@@ -326,21 +326,23 @@ ppc_loo_pit_qq <- function(y,
326326
y_lab <- "LOO-PIT (standard normal quantiles)"
327327
}
328328

329-
ggplot(data.frame(p = pit)) +
329+
qq <- ggplot(data.frame(p = pit)) +
330330
geom_qq(
331331
aes(sample = .data$p),
332332
distribution = theoretical,
333333
color = get_color("m"),
334334
size = size,
335335
alpha = alpha) +
336-
geom_qq_line(
337-
aes(sample = .data$p),
336+
geom_abline(
338337
linetype = 2,
339-
distribution = theoretical,
340-
color = "black",
341-
fullrange = FALSE) +
338+
color = "black") +
342339
bayesplot_theme_get() +
343340
labs(x = x_lab, y = y_lab)
341+
if (compare == "uniform") {
342+
qq + lims(x=c(0,1), y=c(0,1))
343+
} else {
344+
qq
345+
}
344346
}
345347

346348

0 commit comments

Comments
 (0)