Skip to content

Commit 0f68566

Browse files
committed
two small fixes
- ranks should break ties by averaging, according to manuscript - reserve "rank-normalized" for when ranks are normalized (converted to a z or similar scale)
1 parent 6dacc42 commit 0f68566

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

NEWS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<!-- Items for next release go here* -->
88

99
* 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
10+
Rank histograms were introduced by the Stan team's [new paper on
1111
MCMC diagnostics](https://arxiv.org/abs/1903.08008). (#178, #179)
1212

1313
`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.
14+
sampled values the MCMC chains mix over the course of sampling. A rank
15+
histogram (`mcmc_rank_hist()`) visualizes how the *ranks* of values from the
16+
chains mix together. An ideal plot would show the ranks mixing or overlapping
17+
in a uniform distribution.
1818

1919
`mcmc_rank_overlay()`: Instead of drawing each chain's histogram in a separate
2020
panel, this plot draws the top edge of the chains' histograms in a single

R/mcmc-traces.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#' }
5555
#' \item{`mcmc_rank_hist()`}{
5656
#' Whereas traditional trace plots visualize how the chains mix over the
57-
#' course of sampling, rank-normalized histograms visualize how the values
57+
#' course of sampling, rank histograms visualize how the values
5858
#' from the chains mix together in terms of ranking. An ideal plot would
5959
#' show the rankings mixing or overlapping in a uniform distribution.
6060
#' See Vehtari et al. (2019) for details.
@@ -469,7 +469,9 @@ mcmc_trace_data <- function(x,
469469
first_cols <- syms(c("parameter", "value", "value_rank"))
470470
data <- data %>%
471471
group_by(.data$parameter) %>%
472-
mutate(value_rank = dplyr::row_number(.data$value)) %>%
472+
mutate(
473+
value_rank = rank(.data$value, ties.method = "average")
474+
) %>%
473475
ungroup() %>%
474476
select(!!! first_cols, dplyr::everything())
475477

man/MCMC-traces.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)