Skip to content

Commit f27b2e9

Browse files
authored
Merge branch 'master' into hexbin-to-suggests
2 parents a6afc1a + 5eced5b commit f27b2e9

File tree

179 files changed

+17473
-15826
lines changed

Some content is hidden

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

179 files changed

+17473
-15826
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ cache: packages
66

77
r_github_packages:
88
- r-lib/covr
9-
9+
- tidyverse/ggplot2
10+
1011
r_build_args: '--no-build-vignettes'
1112
r_check_args: '--ignore-vignettes'
1213

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ Depends:
2424
Imports:
2525
dplyr (>= 0.8.0),
2626
ggplot2 (>= 2.2.1),
27+
ggridges,
2728
reshape2,
28-
stats,
29-
utils,
3029
rlang (>= 0.3.0),
31-
ggridges
30+
stats,
31+
tibble,
32+
utils
3233
Suggests:
3334
gridExtra (>= 2.2.1),
3435
hexbin,
3536
knitr (>= 1.16),
3637
loo (>= 2.0.0),
38+
RColorBrewer,
3739
rmarkdown (>= 1.0.0),
3840
rstan (>= 2.17.1),
3941
rstanarm (>= 2.17.4),
@@ -45,3 +47,4 @@ Suggests:
4547
RoxygenNote: 6.1.1
4648
VignetteBuilder: knitr
4749
Encoding: UTF-8
50+
Roxygen: list(markdown = TRUE)

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export(mcmc_nuts_treedepth)
7070
export(mcmc_pairs)
7171
export(mcmc_parcoord)
7272
export(mcmc_parcoord_data)
73+
export(mcmc_rank_hist)
74+
export(mcmc_rank_overlay)
7375
export(mcmc_recover_hist)
7476
export(mcmc_recover_intervals)
7577
export(mcmc_recover_scatter)
@@ -78,6 +80,7 @@ export(mcmc_rhat_data)
7880
export(mcmc_rhat_hist)
7981
export(mcmc_scatter)
8082
export(mcmc_trace)
83+
export(mcmc_trace_data)
8184
export(mcmc_trace_highlight)
8285
export(mcmc_violin)
8386
export(neff_ratio)

NEWS.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,31 @@
66

77
<!-- Items for next release go here* -->
88

9+
* Two new plots have been added for inspecting the distribution of ranks.
10+
Rank-normalized histograms were introduced by the Stan team's [new paper on
11+
MCMC diagnostics](https://arxiv.org/abs/1903.08008). (#178, #179)
12+
13+
`mcmc_rank_hist()`: A traditional traceplot (`mcmc_trace()`) visualizes how
14+
sampled values the MCMC chains mix over the course of sampling. A
15+
rank-normalized histogram (`mcmc_rank_hist()`) visualizes how the *ranks* of
16+
values from the chains mix together. An ideal plot would show the ranks mixing
17+
or overlapping in a uniform distribution.
18+
19+
`mcmc_rank_overlay()`: Instead of drawing each chain's histogram in a separate
20+
panel, this plot draws the top edge of the chains' histograms in a single
21+
panel.
22+
23+
* Added `mcmc_trace_data()`, which returns the data used for plotting the trace
24+
plots and rank histograms. (Advances #97)
25+
26+
* [ColorBrewer](http://colorbrewer2.org) palettes are now available as color
27+
schemes via
28+
[`color_scheme_set()`](https://mc-stan.org/bayesplot/reference/bayesplot-colors.html).
29+
For example, `color_scheme_set("brewer-Spectral")` will use the Spectral
30+
palette. (#177, #190)
31+
932
* MCMC plots now also accept objects with an `as.array` method as
10-
input. (#175, #184)
33+
input (e.g., stanfit objects). (#175, #184)
1134

1235
* [`mcmc_trace()`](https://mc-stan.org/bayesplot/reference/MCMC-traces.html)
1336
gains an argument `iter1` which can be used to label the traceplot starting
@@ -43,8 +66,15 @@
4366
* The examples in
4467
[`?ppc_loo_pit_overlay()`](https://mc-stan.org/bayesplot/reference/PPC-loo.html)
4568
now work as expected. (#166, #167)
69+
70+
* Added `"viridisD"` as an alternative name for `"viridis"` to the supported
71+
colors.
72+
73+
* Added `"viridisE"` (the [cividis](https://github.com/marcosci/cividis)
74+
version of viridis) to the supported colors.
4675

47-
* `ppc_bars()` and `ppc_bars_grouped()` now allow negative integers as input. (#172)
76+
* `ppc_bars()` and `ppc_bars_grouped()` now allow negative integers as input.
77+
(#172, @jeffpollock9)
4878

4979

5080
# bayesplot 1.6.0

R/available-module-functions.R

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#' Get or view the names of available plotting functions
22
#'
33
#' @export
4-
#' @param pattern,fixed,invert Passed to \code{\link[base]{grep}}.
4+
#' @param pattern,fixed,invert Passed to [base::grep()].
55
#' @return A possibly empty character vector of function names with several
6-
#' additional attributes (for use by a custom print method). If \code{pattern}
6+
#' additional attributes (for use by a custom print method). If `pattern`
77
#' is missing then the returned object contains the names of all available
8-
#' plotting functions in the \link{MCMC} or \link{PPC} module, depending on
9-
#' which function is called. If \code{pattern} is specified then a subset of
8+
#' plotting functions in the [MCMC] or [PPC] module, depending on
9+
#' which function is called. If `pattern` is specified then a subset of
1010
#' function names is returned.
1111
#'
1212
#' @examples
@@ -17,30 +17,30 @@
1717
#' available_ppc("grouped", invert = TRUE)
1818
#'
1919
available_ppc <- function(pattern, fixed = FALSE, invert = FALSE) {
20-
.list_module_functions("ppc", .pattern = pattern,
21-
fixed = fixed, invert = invert)
20+
.list_module_functions("ppc",
21+
.pattern = pattern,
22+
fixed = fixed,
23+
invert = invert)
2224
}
2325

2426
#' @rdname available_ppc
2527
#' @export
2628
available_mcmc <- function(pattern, fixed = FALSE, invert = FALSE) {
27-
.list_module_functions("mcmc", .pattern = pattern,
28-
fixed = fixed, invert = invert)
29+
.list_module_functions("mcmc",
30+
.pattern = pattern,
31+
fixed = fixed,
32+
invert = invert)
2933
}
3034

3135
#' @export
3236
print.bayesplot_function_list <- function(x, ...) {
3337
atts <- attributes(x)
3438
cat("bayesplot", toupper(atts[["module"]]), "module:\n")
35-
if (!is.null(atts[["pattern"]]))
36-
cat(paste0(
37-
"(",
38-
ifelse(atts[["inverted"]], "excluding", "matching"),
39-
" pattern '",
40-
atts[["pattern"]],
41-
"')"
42-
), "\n")
43-
39+
if (!is.null(atts[["pattern"]])) {
40+
msg <- paste0("(", ifelse(atts[["inverted"]], "excluding", "matching"),
41+
" pattern '", atts[["pattern"]], "')")
42+
cat(msg, "\n")
43+
}
4444
cat(paste0(" ", x), sep = "\n")
4545
invisible(x)
4646
}
@@ -54,26 +54,28 @@ print.bayesplot_function_list <- function(x, ...) {
5454
invert = FALSE) {
5555

5656
.module <- match.arg(.module)
57-
if (missing(.pattern))
57+
if (missing(.pattern)) {
5858
.pattern <- NULL
59+
}
5960

60-
funs <- sort(grep(
61-
paste0("^", .module, "_"),
62-
getNamespaceExports("bayesplot"),
61+
all_funs <- grep(
62+
pattern = paste0("^", .module, "_"),
63+
x = getNamespaceExports("bayesplot"),
6364
value = TRUE
64-
))
65+
)
66+
return_funs <- sort(all_funs)
67+
68+
if (!is.null(.pattern)) {
69+
return_funs <- grep(
70+
pattern = .pattern,
71+
x = return_funs,
72+
value = TRUE,
73+
fixed = fixed,
74+
invert = invert
75+
)
76+
}
6577
structure(
66-
.Data =
67-
if (is.null(.pattern))
68-
funs
69-
else
70-
grep(
71-
pattern = .pattern,
72-
x = funs,
73-
value = TRUE,
74-
fixed = fixed,
75-
invert = invert
76-
),
78+
return_funs,
7779
class = c("bayesplot_function_list", "character"),
7880
module = .module,
7981
pattern = .pattern,

0 commit comments

Comments
 (0)