Skip to content

Commit

Permalink
Merge branch 'master' into prepare-v1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Jan 22, 2024
2 parents 1fe6b67 + 55e5b20 commit 26f02f0
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 264 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Suggests:
survival,
testthat (>= 2.0.0),
vdiffr (>= 1.0.2)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
VignetteBuilder: knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ ADD ANYTHING COMMITTED DIRECTLY TO PR FOR RELEASE (e.g. psis_object argument)

ADD AUTO-GENERATED RELEASE NOTES

* `ppc_pit_ecdf()` and `ppc_pit_ecdf_grouped()` now support discrete variables, and their default method for selecting the number of ECDF evaluation points has been updated.
* Items for next release here

# bayesplot 1.10.0

* New function `mcmc_rank_ecdf()` for rank ecdf plots with confidence bands for
Expand Down Expand Up @@ -50,14 +53,14 @@ previous releases, but the new ones in this release are:
- `ppc_error_hist_grouped()`
- `ppc_error_scatter()`
- `ppc_error_binned()`

* New plotting function `ppc_km_overlay_grouped()`, the grouped variant of
`ppc_km_overlay()`. (#260, @fweber144)

* `ppc_scatter()`, `ppc_scatter_avg()`, and `ppc_scatter_avg_grouped()` gain an
argument `ref_line`, which can be set to `FALSE` to turn off the `x=y` line
drawn behind the scatterplot.

* `ppc_ribbon()` and `ppc_ribbon_grouped()` gain argument `y_draw` that specifies whether the observed y should be plotted using a point, line, or both. (#257, @charlesm93)

* `mcmc_*()` functions now support all draws formats from the **posterior** package. (#277, @Ozan147)
Expand Down
4 changes: 2 additions & 2 deletions R/helpers-ppc.R
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,12 @@ adjust_gamma_simulate <- function(N, L, K, prob, M) {
#' simultaneous coverage of the ECDF traces.
#' @noRd
interpolate_gamma <- function(N, K, prob, L) {
# Find the precomputed values ueful for the interpolation task.
# Find the precomputed values useful for the interpolation task.
vals <- get_interpolation_values(N, K, L, prob)
# Largest lower bound and smalles upper bound for N among precomputed values.
N_lb <- max(vals[vals$N <= N, ]$N)
N_ub <- min(vals[vals$N >= N, ]$N)
# Approximate largest lower bound and smalles upper bound for gamma.
# Approximate largest lower bound and smallest upper bound for gamma.
log_gamma_lb <- approx(
x = log(vals[vals$N == N_lb, ]$K),
y = log(vals[vals$N == N_lb, ]$val),
Expand Down
42 changes: 24 additions & 18 deletions R/ppc-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -606,13 +606,13 @@ ppc_pit_ecdf <- function(y,
if (is.null(pit)) {
pit <- ppc_data(y, yrep) %>%
group_by(.data$y_id) %>%
dplyr::group_map(~ mean(.x$value[.x$is_y] >= .x$value[!.x$is_y])) %>%
dplyr::group_map(
~ mean(.x$value[.x$is_y] > .x$value[!.x$is_y]) +
runif(1, max = mean(.x$value[.x$is_y] == .x$value[!.x$is_y]))
) %>%
unlist()
if (is.null(K)) {
K <- min(
length(unique(ppc_data(y, yrep)$rep_id)) + 1,
length(pit)
)
K <- nrow(yrep) + 1
}
} else {
inform("'pit' specified so ignoring 'y', and 'yrep' if specified.")
Expand All @@ -632,20 +632,22 @@ ppc_pit_ecdf <- function(y,
ggplot() +
aes(
x = 1:K / K,
y = ecdf(pit)(seq(0, 1, length.out = K)) - (plot_diff == TRUE) * 1:K / K,
y = ecdf(pit)(seq(0, 1, length.out = K)) -
(plot_diff == TRUE) * seq(0, 1, length.out = K),
color = "y"
) +
geom_step(show.legend = FALSE) +
geom_step(aes(
y = lims$upper[-1] / N - (plot_diff == TRUE) * 1:K / K,
y = lims$upper[-1] / N - (plot_diff == TRUE) * seq(0, 1, length.out = K),
color = "yrep"
), show.legend = FALSE) +
),
linetype = 2, show.legend = FALSE) +
geom_step(aes(
y = lims$lower[-1] / N - (plot_diff == TRUE) * 1:K / K,
y = lims$lower[-1] / N - (plot_diff == TRUE) * seq(0, 1, length.out = K),
color = "yrep"
), show.legend = FALSE) +
yaxis_title(FALSE) +
xaxis_title(FALSE) +
),
linetype = 2, show.legend = FALSE) +
labs(y = ifelse(plot_diff,"ECDF - difference","ECDF"), x = "PIT") +
yaxis_ticks(FALSE) +
scale_color_ppc() +
bayesplot_theme_get()
Expand All @@ -671,10 +673,13 @@ ppc_pit_ecdf_grouped <-
if (is.null(pit)) {
pit <- ppc_data(y, yrep, group) %>%
group_by(.data$y_id) %>%
dplyr::group_map(~ mean(.x$value[.x$is_y] >= .x$value[!.x$is_y])) %>%
dplyr::group_map(
~ mean(.x$value[.x$is_y] > .x$value[!.x$is_y]) +
runif(1, max = mean(.x$value[.x$is_y] == .x$value[!.x$is_y]))
) %>%
unlist()
if (is.null(K)) {
K <- length(unique(ppc_data(y, yrep)$rep_id)) + 1
K <- nrow(yrep) + 1
}
} else {
inform("'pit' specified so ignoring 'y' and 'yrep' if specified.")
Expand Down Expand Up @@ -723,13 +728,14 @@ ppc_pit_ecdf_grouped <-
geom_step(aes(
y = .data$lims_upper - (plot_diff == TRUE) * .data$x,
color = "yrep"
), show.legend = FALSE) +
),
linetype = 2, show.legend = FALSE) +
geom_step(aes(
y = .data$lims_lower - (plot_diff == TRUE) * .data$x,
color = "yrep"
), show.legend = FALSE) +
xaxis_title(FALSE) +
yaxis_title(FALSE) +
),
linetype = 2, show.legend = FALSE) +
labs(y = ifelse(plot_diff,"ECDF - difference","ECDF"), x = "PIT") +
yaxis_ticks(FALSE) +
bayesplot_theme_get() +
facet_wrap("group") +
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
8 changes: 5 additions & 3 deletions man-roxygen/args-pit-ecdf.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#' @param K An optional integer defining the number of equally spaced evaluation
#' points for the ECDF. If the submitted PIT values are known to be discrete,
#' this should be the number of the discrete cases. Defaults to the smaller of
#' `length(y)` and `ncol(yrep)` when applicable.
#' points for the ECDF. Reducing K when using `interpolate_adj = FALSE` makes
#' computing the confidence bands faster. For `ppc_pit_ecdf` and
#' `ppc_pit_ecdf_grouped`, defaults to `ncol(yrep) + 1`, or `length(pit)` if PIT
#' values are supplied. For `mcmc_rank_ecdf` defaults to the number of
#' iterations per chain in `x`.
#' @param prob The desired simultaneous coverage level of the bands around the
#' ECDF. A value in (0,1).
#' @param plot_diff A boolean defining whether to plot the difference between
Expand Down
8 changes: 5 additions & 3 deletions man/MCMC-traces.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/PPC-distributions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions man/bayesplot-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 26f02f0

Please sign in to comment.