Skip to content

Commit fc63a9b

Browse files
authored
Merge branch 'master' into ridgeline-size
2 parents 639c9f1 + 665c687 commit fc63a9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1337
-302
lines changed

DESCRIPTION

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
Package: bayesplot
22
Type: Package
33
Title: Plotting for Bayesian Models
4-
Version: 1.7.2.9000
5-
Date: 2020-05-27
4+
Version: 1.8.0.9000
5+
Date: 2021-01-07
66
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"), email = "[email protected]"),
77
person("Tristan", "Mahr", role = "aut"),
88
person("Paul-Christian", "Bürkner", role = "ctb"),
99
person("Martin", "Modrák", role = "ctb"),
1010
person("Malcolm", "Barrett", role = "ctb"),
1111
person("Frank", "Weber", role = "ctb"),
12-
person("Eduardo", "Coronado Sroka", role = "ctb"))
12+
person("Eduardo", "Coronado Sroka", role = "ctb"),
13+
person("Aki", "Vehtari", role = "ctb"))
1314
Maintainer: Jonah Gabry <[email protected]>
1415
Description: Plotting functions for posterior analysis, MCMC diagnostics,
1516
prior and posterior predictive checks, and other visualizations
@@ -21,7 +22,7 @@ Description: Plotting functions for posterior analysis, MCMC diagnostics,
2122
particularly (but not exclusively) packages interfacing with 'Stan'.
2223
License: GPL (>= 3)
2324
LazyData: TRUE
24-
URL: https://mc-stan.org/bayesplot
25+
URL: https://mc-stan.org/bayesplot/
2526
BugReports: https://github.com/stan-dev/bayesplot/issues/
2627
SystemRequirements: pandoc (>= 1.12.3), pandoc-citeproc
2728
Depends:

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export(ppc_boxplot)
104104
export(ppc_data)
105105
export(ppc_dens)
106106
export(ppc_dens_overlay)
107+
export(ppc_dens_overlay_grouped)
107108
export(ppc_ecdf_overlay)
109+
export(ppc_ecdf_overlay_grouped)
108110
export(ppc_error_binned)
109111
export(ppc_error_hist)
110112
export(ppc_error_hist_grouped)

NEWS.md

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
<!-- See http://style.tidyverse.org/news.html for advice on writing news -->
22

3+
# bayesplot 1.8.0.9000
34

4-
# bayesplot 1.7.2.9000
5+
Items for next release go here
56

6-
<!--
7-
(GitHub issue/PR numbers in parentheses)
8-
* Items for next release go here
9-
-->
10-
11-
* On the y axis, `ppc_loo_pit_qq(..., compare = "normal")` now plots standard
12-
normal quantiles calculated from the PIT values (instead of the standardized
13-
PIT values). (#240, #243, @fweber144)
7+
* Size of points and interval lines can set in
8+
`mcmc_intervals(..., outer_size, inner_size, point_size)`. (#215, #228, #229)
9+
10+
# bayesplot 1.8.0
1411

15-
* New plotting function `ppc_km_overlay()` for outcome variables that are
16-
right-censored. Empirical CCDF estimates of `yrep` are compared with the
17-
Kaplan-Meier estimate of `y`. (#233, #234, @fweber144)
12+
### Bug fixes
1813

19-
* CmdStanMCMC objects (from CmdStanR) can now be used with extractor
20-
functions `nuts_params()`, `log_posterior()`, `rhat()`, and
21-
`neff_ratio()`. (#227)
14+
* `mcmc_areas()` tries to use less vertical blank space. (#218, #230)
2215

23-
* Size of points and interval lines can set in
24-
`mcmc_intervals(..., outer_size, inner_size, point_size)`. (#215, #228, #229)
25-
26-
* Size of ridgelines can be set in `mcmc_areas(..., size)` and `mcmc_areas_ridges(..., size)`. (#224)
27-
28-
* `mcmc_areas()` tries to use less blank vertical blank space. (#218, #230)
16+
### New features
2917

30-
* Added missing `facet_args` argument to `mcmc_rank_overlay()`. (#221, @hhau)
18+
* New plotting functions `ppc_dens_overlay_grouped()` and `ppc_ecdf_overlay_grouped()`
19+
for plotting density and cumulative distributions of the posterior predictive
20+
distribution (versus observed data) by group. (#212)
3121

22+
* New plotting function `ppc_km_overlay()` for outcome variables that are
23+
right-censored. Empirical CCDF estimates of `yrep` are compared with the
24+
Kaplan-Meier estimate of `y`. (#233, #234, @fweber144)
25+
3226
* `ppc_loo_pit_overlay()` now uses a boundary correction for an improved kernel
3327
density estimation. The new argument `boundary_correction` defaults to TRUE but
3428
can be set to FALSE to recover the old version of the plot. (#171, #235,
3529
@ecoronado92)
3630

31+
* CmdStanMCMC objects (from CmdStanR) can now be used with extractor
32+
functions `nuts_params()`, `log_posterior()`, `rhat()`, and
33+
`neff_ratio()`. (#227)
34+
35+
* On the y axis, `ppc_loo_pit_qq(..., compare = "normal")` now plots standard
36+
normal quantiles calculated from the PIT values (instead of the standardized
37+
PIT values). (#240, #243, @fweber144)
38+
39+
* `mcmc_rank_overlay()` gains argument `facet_args`. (#221, @hhau)
40+
41+
* For `mcmc_intervals()` the size` of the points and interval lines can be set with
42+
`mcmc_intervals(..., outer_size, inner_size, point_size)`. (#215, #228, #229)
43+
44+
3745

3846
# bayesplot 1.7.2
3947

@@ -54,39 +62,39 @@ matrices also inheriting from "array" in R 4.0.
5462
examples. (#161, #183, #188)
5563

5664
* Two new plots have been added for inspecting the distribution of ranks.
57-
Rank histograms were introduced by the Stan team's [new paper on
65+
Rank histograms were introduced by the Stan team's [new paper on
5866
MCMC diagnostics](https://arxiv.org/abs/1903.08008). (#178, #179)
5967

6068
`mcmc_rank_hist()`: A traditional traceplot (`mcmc_trace()`) visualizes how
6169
sampled values the MCMC chains mix over the course of sampling. A rank
6270
histogram (`mcmc_rank_hist()`) visualizes how the *ranks* of values from the
6371
chains mix together. An ideal plot would show the ranks mixing or overlapping
6472
in a uniform distribution.
65-
73+
6674
`mcmc_rank_overlay()`: Instead of drawing each chain's histogram in a separate
6775
panel, this plot draws the top edge of the chains' histograms in a single
6876
panel.
69-
77+
7078
* Added `mcmc_trace_data()`, which returns the data used for plotting the trace
7179
plots and rank histograms. (Advances #97)
7280

73-
* [ColorBrewer](http://colorbrewer2.org) palettes are now available as color
81+
* [ColorBrewer](https://colorbrewer2.org/) palettes are now available as color
7482
schemes via
7583
[`color_scheme_set()`](https://mc-stan.org/bayesplot/reference/bayesplot-colors.html).
76-
For example, `color_scheme_set("brewer-Spectral")` will use the Spectral
84+
For example, `color_scheme_set("brewer-Spectral")` will use the Spectral
7785
palette. (#177, #190)
7886

79-
* MCMC plots now also accept objects with an `as.array` method as
87+
* MCMC plots now also accept objects with an `as.array` method as
8088
input (e.g., stanfit objects). (#175, #184)
8189

8290
* [`mcmc_trace()`](https://mc-stan.org/bayesplot/reference/MCMC-traces.html)
8391
gains an argument `iter1` which can be used to label the traceplot starting
8492
from the first iteration after warmup. (#14, #155, @mcol)
8593

8694
* [`mcmc_areas()`](https://mc-stan.org/bayesplot/reference/MCMC-intervals.html)
87-
gains an argument `area_method` which controls how to draw the density
88-
curves. The default `"equal area"` constrains the heights so that the curves
89-
have the same area. As a result, a narrow interval will appear as a spike
95+
gains an argument `area_method` which controls how to draw the density
96+
curves. The default `"equal area"` constrains the heights so that the curves
97+
have the same area. As a result, a narrow interval will appear as a spike
9098
of density, while a wide, uncertain interval is spread thin over the _x_ axis.
9199
Alternatively `"equal height"` will set the maximum height on each curve to
92100
the same value. This works well when the intervals are about the same width.
@@ -113,12 +121,12 @@ matrices also inheriting from "array" in R 4.0.
113121
* The examples in
114122
[`?ppc_loo_pit_overlay()`](https://mc-stan.org/bayesplot/reference/PPC-loo.html)
115123
now work as expected. (#166, #167)
116-
117-
* Added `"viridisD"` as an alternative name for `"viridis"` to the supported
124+
125+
* Added `"viridisD"` as an alternative name for `"viridis"` to the supported
118126
colors.
119127

120-
* Added `"viridisE"` (the [cividis](https://github.com/marcosci/cividis)
121-
version of viridis) to the supported colors.
128+
* Added `"viridisE"` (the [cividis](https://github.com/marcosci/cividis)
129+
version of viridis) to the supported colors.
122130

123131
* `ppc_bars()` and `ppc_bars_grouped()` now allow negative integers as input.
124132
(#172, @jeffpollock9)
@@ -161,7 +169,7 @@ matrices also inheriting from "array" in R 4.0.
161169
gains an argument `discrete`, which is `FALSE` by default, but can be used
162170
to make the Geom more appropriate for discrete data. (#145)
163171

164-
* [PPC intervals
172+
* [PPC intervals
165173
plots](https://mc-stan.org/bayesplot/reference/PPC-intervals.html) and [LOO
166174
predictive checks](https://mc-stan.org/bayesplot/reference/PPC-loo.html) now
167175
draw both an outer and an inner probability interval, which can be

R/bayesplot-colors.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ plot_scheme <- function(scheme = NULL) {
230230
legend_none() +
231231
xaxis_text(
232232
face = "bold",
233-
margin = margin(t = -3, b = 10),
233+
margin = margin(t = -3, b = 10, unit = "pt"),
234234
angle = 0,
235+
vjust = 1,
235236
debug = FALSE
236237
)
237238
}

R/bayesplot-package.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#'
4545
#' @section Resources:
4646
#' * __Online documentation and vignettes__: Visit the __bayesplot__ website at
47-
#' <https://mc-stan.org/bayesplot>
47+
#' <https://mc-stan.org/bayesplot/>
4848
#' * __Bug reports and feature requests__: If you would like to request a new
4949
#' feature or if you have noticed a bug that needs to be fixed please let us
5050
#' know at the **bayesplot** issue tracker at

R/mcmc-diagnostics.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@ acf_data <- function(x, lags) {
580580
abort(paste0("Too few iterations for lags=", lags, "."))
581581
}
582582

583-
data <- reshape2::melt(x, value.name = "Value")
584-
data$Chain <- factor(data$Chain)
583+
data <- melt_mcmc(x)
585584
ac_list <- tapply(
586585
data[["Value"]],
587586
# INDEX = list(data[["Chain"]], data[["Parameter"]]),

R/mcmc-intervals.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@
9494
#' expand = expansion(add = c(.1, .3))
9595
#' )
9696
#'
97+
#' # relabel parameters
98+
#' p + scale_y_discrete(
99+
#' labels = c("alpha" = "param label 1",
100+
#' "beta[4]" = "param label 2")
101+
#')
102+
#'
103+
#' # relabel parameters and define the order
104+
#' p + scale_y_discrete(
105+
#' labels = c("alpha" = "param label 1",
106+
#' "beta[4]" = "param label 2"),
107+
#' limits = c("beta[4]", "alpha")
108+
#' )
109+
#'
97110
#' # color by rhat value
98111
#' color_scheme_set("blue")
99112
#' fake_rhat_values <- c(1, 1.07, 1.3, 1.01, 1.15, 1.005)

R/ppc-censoring.R

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
#' predictive distribution. See the **Plot Descriptions** section, below, for
66
#' details.
77
#'
8-
#' Although some of the other plots can be used with censored data,
9-
#' `ppc_km_overlay()` is currently the only plotting function designed
8+
#' Although some of the other \pkg{bayesplot} plots can be used with censored
9+
#' data, `ppc_km_overlay()` is currently the only plotting function designed
1010
#' *specifically* for censored data. We encourage you to suggest or contribute
11-
#' additional plots at [https://github.com/stan-dev/bayesplot](github.com/stan-dev/bayesplot).
12-
#'
13-
#'
11+
#' additional plots at
12+
#' [github.com/stan-dev/bayesplot](https://github.com/stan-dev/bayesplot).
1413
#'
1514
#' @name PPC-censoring
1615
#' @family PPCs
@@ -26,10 +25,10 @@
2625
#' \describe{
2726
#' \item{`ppc_km_overlay()`}{
2827
#' Empirical CCDF estimates of each dataset (row) in `yrep` are overlaid,
29-
#' with the Kaplan-Meier estimate (Kaplan and Meier, 1958) for `y` itself
30-
#' on top (and in a darker shade). This is a PPC suitable for
31-
#' right-censored `y`. Note that the replicated data from `yrep` is assumed
32-
#' to be uncensored.
28+
#' with the Kaplan-Meier estimate (Kaplan and Meier, 1958) for `y` itself on
29+
#' top (and in a darker shade). This is a PPC suitable for right-censored
30+
#' `y`. Note that the replicated data from `yrep` is assumed to be
31+
#' uncensored.
3332
#' }
3433
#' }
3534
#'
@@ -74,11 +73,9 @@ ppc_km_overlay <-
7473
abort("Package 'ggfortify' required.")
7574
}
7675

77-
# Checks for 'status_y':
7876
stopifnot(is.numeric(status_y))
7977
stopifnot(all(status_y %in% c(0, 1)))
8078

81-
# Create basic PPC dataset:
8279
data <- ppc_data(y, yrep, group = status_y)
8380

8481
# Modify the status indicator:
@@ -93,23 +90,20 @@ ppc_km_overlay <-
9390
as.numeric(as.character(.data$group)),
9491
1))
9592

96-
# Create 'survfit' object and 'fortify' it
9793
sf <- survival::survfit(
9894
survival::Surv(value, group) ~ rep_label,
9995
data = data
10096
)
10197
fsf <- fortify(sf)
10298

103-
# Add variables specifying color, size, and alpha:
10499
fsf$is_y_color <- as.factor(sub("\\[rep\\] \\(.*$", "rep", sub("^italic\\(y\\)", "y", fsf$strata)))
105100
fsf$is_y_size <- ifelse(fsf$is_y_color == "yrep", size, 1)
106101
fsf$is_y_alpha <- ifelse(fsf$is_y_color == "yrep", alpha, 1)
107102

108103
# Ensure that the observed data gets plotted last by reordering the
109-
# levels of the factor "strata":
104+
# levels of the factor "strata"
110105
fsf$strata <- factor(fsf$strata, levels = rev(levels(fsf$strata)))
111106

112-
# Plot:
113107
ggplot(data = fsf,
114108
mapping = aes_(x = ~ time,
115109
y = ~ surv,

0 commit comments

Comments
 (0)