Skip to content

Commit 51234bb

Browse files
authored
Merge pull request #311 from stan-dev/prepare-v1.11.0
Prepare v1.11.0
2 parents 55e5b20 + df74163 commit 51234bb

11 files changed

+148
-75
lines changed

DESCRIPTION

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: bayesplot
22
Type: Package
33
Title: Plotting for Bayesian Models
4-
Version: 1.10.0.9001
5-
Date: 2023-03-16
4+
Version: 1.11.0
5+
Date: 2024-01-30
66
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"), email = "jsg2201@columbia.edu"),
77
person("Tristan", "Mahr", role = "aut"),
88
person("Paul-Christian", "Bürkner", role = "ctb"),
@@ -29,8 +29,8 @@ Depends:
2929
R (>= 3.1.0)
3030
Imports:
3131
dplyr (>= 0.8.0),
32-
ggplot2 (>= 3.0.0),
33-
ggridges,
32+
ggplot2 (>= 3.4.0),
33+
ggridges (>= 0.5.5),
3434
glue,
3535
posterior,
3636
reshape2,

NAMESPACE

+15
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,31 @@
22

33
S3method("[",neff_ratio)
44
S3method("[",rhat)
5+
S3method(apply_transformations,array)
6+
S3method(apply_transformations,matrix)
7+
S3method(diagnostic_factor,neff_ratio)
8+
S3method(diagnostic_factor,rhat)
59
S3method(log_posterior,CmdStanMCMC)
610
S3method(log_posterior,stanfit)
711
S3method(log_posterior,stanreg)
12+
S3method(melt_mcmc,matrix)
13+
S3method(melt_mcmc,mcmc_array)
814
S3method(neff_ratio,CmdStanMCMC)
915
S3method(neff_ratio,stanfit)
1016
S3method(neff_ratio,stanreg)
17+
S3method(num_chains,data.frame)
18+
S3method(num_chains,mcmc_array)
19+
S3method(num_iters,data.frame)
20+
S3method(num_iters,mcmc_array)
21+
S3method(num_params,data.frame)
22+
S3method(num_params,mcmc_array)
1123
S3method(nuts_params,CmdStanMCMC)
1224
S3method(nuts_params,list)
1325
S3method(nuts_params,stanfit)
1426
S3method(nuts_params,stanreg)
27+
S3method(parameter_names,array)
28+
S3method(parameter_names,default)
29+
S3method(parameter_names,matrix)
1530
S3method(plot,bayesplot_grid)
1631
S3method(plot,bayesplot_scheme)
1732
S3method(pp_check,default)

NEWS.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
<!-- See http://style.tidyverse.org/news.html for advice on writing news -->
22

3-
# bayesplot 1.10.0.9000
4-
5-
* `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.
6-
* Items for next release here
3+
# bayesplot 1.11.0
4+
5+
* Update for new ggplot2 release by @teunbrand in #309
6+
* Add `bins` argument to many histogram plots by @paul-buerkner in #300
7+
* Follow ggplot2 updates on `facet_grid()` and `facet_wrap()` by @heavywatal in #305
8+
* Better `ppc_loo_pit_qq` plots by @avehtari in #307
9+
* Check `prob` is numeric for intervals plots by @tony-stone in #299
10+
* Add `bins` and `breaks` arguments to more histogram and hex plots by @heavywatal in #313
11+
* Replace `size` argument with `linewidth` for `geom_line` and `geom_ridgeline` by @heavywatal in #314
12+
* All LOO plots now accept `psis_object` argument by @jgabry in #311
13+
* `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. by @TeemuSailynoja in #316
714

815
# bayesplot 1.10.0
916

@@ -49,14 +56,14 @@ previous releases, but the new ones in this release are:
4956
- `ppc_error_hist_grouped()`
5057
- `ppc_error_scatter()`
5158
- `ppc_error_binned()`
52-
59+
5360
* New plotting function `ppc_km_overlay_grouped()`, the grouped variant of
5461
`ppc_km_overlay()`. (#260, @fweber144)
5562

5663
* `ppc_scatter()`, `ppc_scatter_avg()`, and `ppc_scatter_avg_grouped()` gain an
5764
argument `ref_line`, which can be set to `FALSE` to turn off the `x=y` line
5865
drawn behind the scatterplot.
59-
66+
6067
* `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)
6168

6269
* `mcmc_*()` functions now support all draws formats from the **posterior** package. (#277, @Ozan147)

R/helpers-mcmc.R

+22-5
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ prepare_mcmc_array <- function(x,
5151
if (is.matrix(x)) {
5252
x <- x[, pars, drop=FALSE]
5353
if (length(transformations)) {
54-
x <- apply_transformations(x, transformations)
54+
x <- apply_transformations(x, transformations = transformations)
5555
}
5656
x <- array(x, dim = c(nrow(x), 1, ncol(x)))
5757
} else {
5858
x <- x[, , pars, drop = FALSE]
5959
if (length(transformations)) {
60-
x <- apply_transformations(x, transformations)
60+
x <- apply_transformations(x, transformations = transformations)
6161
}
6262
}
6363

@@ -124,6 +124,8 @@ select_parameters <-
124124
#' @return A molten data frame.
125125
#'
126126
melt_mcmc <- function(x, ...) UseMethod("melt_mcmc")
127+
128+
#' @export
127129
melt_mcmc.mcmc_array <- function(x,
128130
varnames =
129131
c("Iteration", "Chain", "Parameter"),
@@ -144,6 +146,7 @@ melt_mcmc.mcmc_array <- function(x,
144146
}
145147

146148
# If all chains are already merged
149+
#' @export
147150
melt_mcmc.matrix <- function(x,
148151
varnames = c("Draw", "Parameter"),
149152
value.name = "Value",
@@ -305,13 +308,17 @@ chain_list2array <- function(x) {
305308

306309
# Get parameter names from a 3-D array
307310
parameter_names <- function(x) UseMethod("parameter_names")
311+
312+
#' @export
308313
parameter_names.array <- function(x) {
309314
stopifnot(is_3d_array(x))
310315
dimnames(x)[[3]] %||% abort("No parameter names found.")
311316
}
317+
#' @export
312318
parameter_names.default <- function(x) {
313319
colnames(x) %||% abort("No parameter names found.")
314320
}
321+
#' @export
315322
parameter_names.matrix <- function(x) {
316323
colnames(x) %||% abort("No parameter names found.")
317324
}
@@ -388,10 +395,12 @@ validate_transformations <-
388395
#' functions.
389396
#' @return x, with tranformations having been applied to some parameters.
390397
#'
391-
apply_transformations <- function(x, transformations = list(), ...) {
398+
apply_transformations <- function(x, ...) {
392399
UseMethod("apply_transformations")
393400
}
394-
apply_transformations.matrix <- function(x, transformations = list()) {
401+
402+
#' @export
403+
apply_transformations.matrix <- function(x, ..., transformations = list()) {
395404
pars <- colnames(x)
396405
x_transforms <- validate_transformations(transformations, pars)
397406
for (p in names(x_transforms)) {
@@ -400,7 +409,9 @@ apply_transformations.matrix <- function(x, transformations = list()) {
400409

401410
x
402411
}
403-
apply_transformations.array <- function(x, transformations = list()) {
412+
413+
#' @export
414+
apply_transformations.array <- function(x, ..., transformations = list()) {
404415
stopifnot(length(dim(x)) == 3)
405416
pars <- dimnames(x)[[3]]
406417
x_transforms <- validate_transformations(transformations, pars)
@@ -437,17 +448,23 @@ num_chains <- function(x, ...) UseMethod("num_chains")
437448
num_iters <- function(x, ...) UseMethod("num_iters")
438449
num_params <- function(x, ...) UseMethod("num_params")
439450

451+
#' @export
440452
num_params.mcmc_array <- function(x, ...) dim(x)[3]
453+
#' @export
441454
num_chains.mcmc_array <- function(x, ...) dim(x)[2]
455+
#' @export
442456
num_iters.mcmc_array <- function(x, ...) dim(x)[1]
457+
#' @export
443458
num_params.data.frame <- function(x, ...) {
444459
stopifnot("Parameter" %in% colnames(x))
445460
length(unique(x$Parameter))
446461
}
462+
#' @export
447463
num_chains.data.frame <- function(x, ...) {
448464
stopifnot("Chain" %in% colnames(x))
449465
length(unique(x$Chain))
450466
}
467+
#' @export
451468
num_iters.data.frame <- function(x, ...) {
452469
cols <- colnames(x)
453470
stopifnot("Iteration" %in% cols || "Draws" %in% cols)

R/mcmc-diagnostics.R

+5-3
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,19 @@ mcmc_acf_bar <-
360360
#' `x <= breaks[1]`, `breaks[1] < x <= breaks[2]`, `x > breaks[2]`).
361361
#' @return A factor the same length as `x` with three levels.
362362
#' @noRd
363-
diagnostic_factor <- function(x, breaks, ...) {
363+
diagnostic_factor <- function(x, ...) {
364364
UseMethod("diagnostic_factor")
365365
}
366366

367-
diagnostic_factor.rhat <- function(x, breaks = c(1.05, 1.1)) {
367+
#' @export
368+
diagnostic_factor.rhat <- function(x, ..., breaks = c(1.05, 1.1)) {
368369
cut(x, breaks = c(-Inf, breaks, Inf),
369370
labels = c("low", "ok", "high"),
370371
ordered_result = FALSE)
371372
}
372373

373-
diagnostic_factor.neff_ratio <- function(x, breaks = c(0.1, 0.5)) {
374+
#' @export
375+
diagnostic_factor.neff_ratio <- function(x, ..., breaks = c(0.1, 0.5)) {
374376
cut(x, breaks = c(-Inf, breaks, Inf),
375377
labels = c("low", "ok", "high"),
376378
ordered_result = FALSE)

R/ppc-discrete.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ ppc_bars_data <-
367367
#' @param y,yrep,group User's already validated `y`, `yrep`, and (if applicable)
368368
#' `group` arguments.
369369
#' @param prob,freq User's `prob` and `freq` arguments.
370-
#' @importFrom dplyr "%>%" ungroup count arrange mutate summarise across full_join rename all_of
370+
#' @importFrom dplyr %>% ungroup count arrange mutate summarise across full_join rename all_of
371371
.ppc_bars_data <- function(y, yrep, group = NULL, prob = 0.9, freq = TRUE) {
372372
alpha <- (1 - prob) / 2
373373
probs <- sort(c(alpha, 0.5, 1 - alpha))

0 commit comments

Comments
 (0)