Skip to content

Commit fdcf6a2

Browse files
committed
fix some warnings/errors
Pretty much closes #191
1 parent 946fe1f commit fdcf6a2

36 files changed

+1193
-1268
lines changed

R/bayesplot-colors.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ color_scheme_set <- function(scheme = "blue") {
142142
}
143143

144144
#' @rdname bayesplot-colors
145-
#' @md
146145
#' @export
147146
#' @param i For `color_scheme_get()`, an optional subset of the integers from `1`
148147
#' (lightest) to `6` (darkest) indicating which of the colors in the

R/bayesplot-helpers.R

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,22 @@
4646
#' the lower and upper bounds (`lb`, `ub`) of the `100*p`\% central interval
4747
#' of `x`, as well as the median (if `med=TRUE`).
4848
#' }
49+
#'
4950
#' \subsection{Control appearance of facet strips}{
50-
#' * `facet_text()` and `facet_bg()` return ggplot2 theme objects that
51-
#' can be added to an existing plot (ggplot object) to format the text and the
52-
#' background for the facet strips.
51+
#' * `facet_text()` returns ggplot2 theme objects that can be added to an
52+
#' existing plot (ggplot object) to format the text in facet strips.
53+
#'
54+
#' * `facet_bg()` can be added to a plot to change the background of the facet strips.
5355
#' }
56+
#'
5457
#' \subsection{Move legend, remove legend, or style the legend text}{
55-
#' * `legend_move()` and `legend_none()` return a ggplot2 theme object
56-
#' that can be added to an existing plot (ggplot object) in order to change the
57-
#' position of the legend (`legend_move()`) or remove the legend
58-
#' (`legend_none()`). `legend_text()` works much like `facet_text()`,
59-
#' except it controls the legend text.
58+
#' * `legend_move()` and `legend_none()` return a ggplot2 theme object that can
59+
#' be added to an existing plot (ggplot object) in order to change the
60+
#' position of the legend or remove it.
61+
#'
62+
#' * `legend_text()` works much like `facet_text()` but for the legend.
6063
#' }
64+
#'
6165
#' \subsection{Control appearance of \eqn{x}-axis and \eqn{y}-axis features}{
6266
#' * `xaxis_title()` and `yaxis_title()` return a ggplot2 theme object
6367
#' that can be added to an existing plot (ggplot object) in order to toggle or
@@ -73,21 +77,24 @@
7377
#' that can be added to an existing plot (ggplot object) to change the
7478
#' appearance of the axis tick marks.
7579
#' }
80+
#'
7681
#' \subsection{Customize plot background}{
7782
#' * `plot_bg()` returns a ggplot2 theme object that can be added to an
78-
#' existing plot (ggplot object) to format the background of the *entire* plot.
83+
#' existing plot (ggplot object) to format the background of the *entire* plot.
84+
#'
7985
#' * `panel_bg()` returns a ggplot2 theme object that can be added to an
80-
#' existing plot (ggplot object) to format the background of the just the
81-
#' plotting area.
86+
#' existing plot (ggplot object) to format the background of the just the
87+
#' plotting area.
88+
#'
8289
#' * `grid_lines()` returns a ggplot2 theme object that can be added to
83-
#' an existing plot (ggplot object) to add grid lines to the plot background.
90+
#' an existing plot (ggplot object) to add grid lines to the plot background.
8491
#' }
92+
#'
8593
#' \subsection{Superimpose a function on an existing plot}{
86-
#' * `overlay_function()` is a simple wrapper for
87-
#' [ggplot2::stat_function()] but with the `inherit.aes` argument
88-
#' fixed to `FALSE`. Fixing `inherit.aes=FALSE` will avoid potential
89-
#' errors due to the [ggplot2::aes()]thetic mapping used by certain
90-
#' **bayesplot** plotting functions.
94+
#' * `overlay_function()` is a simple wrapper for [ggplot2::stat_function()] but
95+
#' with the `inherit.aes` argument fixed to `FALSE`. Fixing `inherit.aes=FALSE`
96+
#' will avoid potential errors due to the [ggplot2::aes()]thetic mapping used by
97+
#' certain **bayesplot** plotting functions.
9198
#' }
9299
#'
93100
#' @seealso [theme_default()] for the default ggplot theme used by
@@ -284,7 +291,7 @@ abline_01 <- function(..., na.rm = TRUE) {
284291
# intervals ---------------------------------------------------------------
285292
#' @rdname bayesplot-helpers
286293
#' @export
287-
#' @param p The probability mass (in `[0,1]``) to include in the interval.
294+
#' @param p The probability mass (in `[0,1]`) to include in the interval.
288295
#' @param med Should the median also be included in addition to the lower
289296
#' and upper bounds of the interval?
290297
#'

R/bayesplot-package.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#' * __General questions and help__:
5050
#' To ask a question about **bayesplot** on the Stan Forums forum please visit
5151
#' <https://discourse.mc-stan.org>.
52-
#' }
5352
#'
5453
#' @template seealso-theme
5554
#' @template seealso-colors

R/bayesplot_grid.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#' Setting this to `FALSE` will make the returned object smaller but
2424
#' these individual plot objects will not be available.
2525
#'
26-
#' @return An object of class "bayesplot_grid" (essentially a gtable object from
27-
#' [gridExtra::arrangeGrob()]), which has a `plot` method.
26+
#' @return An object of class `"bayesplot_grid"` (essentially a gtable object
27+
#' from [gridExtra::arrangeGrob()]), which has a `plot` method.
2828
#'
2929
#' @examples
3030
#' y <- example_y_data()

R/mcmc-diagnostics-nuts.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,26 @@
5151
#' lines indicating the mean (solid line) and median (dashed line).
5252
#' * Scatterplot of `accept_stat__` vs `lp__`.
5353
#' }
54+
#'
5455
#' \item{`mcmc_nuts_divergence()`}{
5556
#' Two plots:
5657
#' * Violin plots of `lp__|divergent__=1` and `lp__|divergent__=0`.
5758
#' * Violin plots of `accept_stat__|divergent__=1` and `accept_stat__|divergent__=0`.
5859
#' }
60+
#'
5961
#' \item{`mcmc_nuts_stepsize()`}{
6062
#' Two plots:
6163
#' * Violin plots of `lp__` by chain ordered by `stepsize__` value.
6264
#' * Violin plots of `accept_stat__` by chain ordered by `stepsize__` value.
6365
#' }
66+
#'
6467
#' \item{`mcmc_nuts_treedepth()`}{
6568
#' Three plots:
6669
#' * Violin plots of `lp__` by value of `treedepth__`.
6770
#' * Violin plots of `accept_stat__` by value of `treedepth__`.
6871
#' * Histogram of `treedepth__`.
6972
#' }
73+
#'
7074
#' \item{`mcmc_nuts_energy()`}{
7175
#' Overlaid histograms showing `energy__` vs the change in
7276
#' `energy__`. See Betancourt (2016) for details.

R/mcmc-diagnostics.R

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,29 @@
1919
#' @section Plot Descriptions:
2020
#' \describe{
2121
#' \item{`mcmc_rhat()`, `mcmc_rhat_hist()`}{
22-
#' Rhat values as either points or a histogram. Values are colored using
23-
#' different shades (lighter is better). The chosen thresholds are somewhat
24-
#' arbitrary, but can be useful guidelines in practice.
25-
#' * _light_: below 1.05 (good)
26-
#' * _mid_: between 1.05 and 1.1 (ok)
27-
#' * _dark_: above 1.1 (too high)
22+
#' Rhat values as either points or a histogram. Values are colored using
23+
#' different shades (lighter is better). The chosen thresholds are somewhat
24+
#' arbitrary, but can be useful guidelines in practice.
25+
#' * _light_: below 1.05 (good)
26+
#' * _mid_: between 1.05 and 1.1 (ok)
27+
#' * _dark_: above 1.1 (too high)
2828
#' }
29+
#'
2930
#' \item{`mcmc_neff()`, `mcmc_neff_hist()`}{
30-
#' Ratios of effective sample size to total sample size as either points or a
31-
#' histogram. Values are colored using different shades (lighter is better). The
32-
#' chosen thresholds are somewhat arbitrary, but can be useful guidelines in
33-
#' practice.
34-
#' * _light_: between 0.5 and 1 (high)
35-
#' * _mid_: between 0.1 and 0.5 (good)
36-
#' * _dark_: below 0.1 (low)
37-
#' }
31+
#' Ratios of effective sample size to total sample size as either points or a
32+
#' histogram. Values are colored using different shades (lighter is better).
33+
#' The chosen thresholds are somewhat arbitrary, but can be useful guidelines
34+
#' in practice.
35+
#' * _light_: between 0.5 and 1 (high)
36+
#' * _mid_: between 0.1 and 0.5 (good)
37+
#' * _dark_: below 0.1 (low)
3838
#' }
39+
#'
3940
#' \item{`mcmc_acf()`, `mcmc_acf_bar()`}{
40-
#' Grid of autocorrelation plots by chain and parameter. The `lags`
41-
#' argument gives the maximum number of lags at which to calculate the
42-
#' autocorrelation function. `mcmc_acf()` is a line plot whereas
43-
#' `mcmc_acf_bar()` is a barplot.
41+
#' Grid of autocorrelation plots by chain and parameter. The `lags` argument
42+
#' gives the maximum number of lags at which to calculate the autocorrelation
43+
#' function. `mcmc_acf()` is a line plot whereas `mcmc_acf_bar()` is a
44+
#' barplot.
4445
#' }
4546
#'}
4647
#'

R/mcmc-traces.R

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,29 @@
1313
#' @template args-facet_args
1414
#' @param ... Currently ignored.
1515
#' @param size An optional value to override the default line size
16-
#' (`mcmc_trace`) or the default point size
17-
#' (`mcmc_trace_highlight`).
18-
#' @param alpha For `mcmc_trace_highlight`, passed to
16+
#' (`mcmc_trace()`) or the default point size
17+
#' (`mcmc_trace_highlight()`).
18+
#' @param alpha For `mcmc_trace_highlight()`, passed to
1919
#' [ggplot2::geom_point()] to control the transparency of the points
2020
#' for the chains not highlighted.
2121
#' @param n_warmup An integer; the number of warmup iterations included in
2222
#' `x`. The default is `n_warmup = 0`, i.e. to assume no warmup
2323
#' iterations are included. If `n_warmup > 0` then the background for
2424
#' iterations `1:n_warmup` is shaded gray.
2525
#' @param iter1 An integer; the iteration number of the first included draw
26-
#' (default 0). This can be used to make it more obvious that the warmup
26+
#' (default is `0`). This can be used to make it more obvious that the warmup
2727
#' iterations have been discarded from the traceplot. It cannot be specified
2828
#' if `n_warmup` is also set to a positive value.
2929
#' @param window An integer vector of length two specifying the limits of a
3030
#' range of iterations to display.
31-
#' @param np For models fit using [NUTS()] (more generally, any
32-
#' \href{https://en.wikipedia.org/wiki/Symplectic_integrator}{symplectic
33-
#' integrator}), an optional data frame providing NUTS diagnostic
34-
#' information. The data frame should be the object returned by
35-
#' [nuts_params()] or one with the same structure. If `np` is
36-
#' specified then tick marks are added to the bottom of the trace plot
37-
#' indicating within which iterations there was a divergence (if there were any).
38-
#' See the end of the **Examples** section, below.
39-
#' @param np_style A call to the `trace_style_np` helper function to
31+
#' @param np For models fit using [NUTS] (more generally, any
32+
#' (https://en.wikipedia.org/wiki/Symplectic_integrator)[symplectic integrator]),
33+
#' an optional data frame providing NUTS diagnostic information. The data
34+
#' frame should be the object returned by [nuts_params()] or one with the same
35+
#' structure. If `np` is specified then tick marks are added to the bottom of
36+
#' the trace plot indicating within which iterations there was a divergence
37+
#' (if there were any). See the end of the **Examples** section, below.
38+
#' @param np_style A call to the `trace_style_np()` helper function to
4039
#' specify arguments controlling the appearance of tick marks representing
4140
#' divergences (if the `np` argument is specified).
4241
#' @param divergences Deprecated. Use the `np` argument instead.
@@ -45,11 +44,11 @@
4544
#'
4645
#' @section Plot Descriptions:
4746
#' \describe{
48-
#' \item{`mcmc_trace`}{
49-
#' Standard trace plots of MCMC draws. For models fit using [NUTS()],
47+
#' \item{`mcmc_trace()`}{
48+
#' Standard trace plots of MCMC draws. For models fit using [NUTS],
5049
#' the `np` argument can be used to also show divergences on the trace plot.
5150
#' }
52-
#' \item{`mcmc_trace_highlight`}{
51+
#' \item{`mcmc_trace_highlight()`}{
5352
#' Traces are plotted using points rather than lines and the opacity of all
5453
#' chains but one (specified by the `highlight` argument) is reduced.
5554
#' }
@@ -192,7 +191,7 @@ mcmc_trace <-
192191

193192
#' @rdname MCMC-traces
194193
#' @export
195-
#' @param highlight For `mcmc_trace_highlight`, an integer specifying one
194+
#' @param highlight For `mcmc_trace_highlight()`, an integer specifying one
196195
#' of the chains that will be more visible than the others in the plot.
197196
mcmc_trace_highlight <-
198197
function(x,
@@ -227,11 +226,10 @@ mcmc_trace_highlight <-
227226
#' @rdname MCMC-traces
228227
#' @export
229228
#' @param div_color,div_size,div_alpha Optional arguments to the
230-
#' `trace_style_np` helper function that are eventually passed to
231-
#' [ggplot2::geom_rug()] if the `np` argument is also
232-
#' specified. They control the color, size, and transparency specifications
233-
#' for showing divergences in the plot. The default values are displayed in
234-
#' the \strong{Usage} section above.
229+
#' `trace_style_np()` helper function that are eventually passed to
230+
#' [ggplot2::geom_rug()] if the `np` argument is also specified. They control
231+
#' the color, size, and transparency specifications for showing divergences in
232+
#' the plot. The default values are displayed in the **Usage** section above.
235233
trace_style_np <-
236234
function(div_color = "red",
237235
div_size = 0.25,
@@ -391,16 +389,17 @@ chain_colors <- function(n) {
391389
}
392390

393391

394-
# Add divergences to trace plot using geom_rug
395-
#
396-
# @param np User's 'np' argument, if specified.
397-
# @param np_style User's 'np_style' argument, if specified.
398-
# @param n_iter Number of iterations in the trace plot (to check against number
399-
# of iterations provided in 'np').
400-
# @param n_chain Number of chains in the trace plot (to check against number
401-
# of chains provided in 'np').
402-
# @return Object returned by geom_rug.
403-
#
392+
#' Add divergences to trace plot using geom_rug
393+
#'
394+
#' @noRd
395+
#' @param np User's `np` argument, if specified.
396+
#' @param np_style User's `np_style` argument, if specified.
397+
#' @param n_iter Number of iterations in the trace plot (to check against number
398+
#' of iterations provided in `np`).
399+
#' @param n_chain Number of chains in the trace plot (to check against number
400+
#' of chains provided in `np`).
401+
#' @return Object returned by `ggplot2::geom_rug()`.
402+
#'
404403
#' @importFrom dplyr summarise group_by select
405404
divergence_rug <- function(np, np_style, n_iter, n_chain) {
406405
if (is.data.frame(np)) {

R/ppc-overview.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@
5151
#' Chapter 6 of Gelman et. al. (2013).
5252
#' }
5353
#'
54-
#' @section PPC plotting functions:
55-
#'
56-
#' The plotting functions for posterior predictive checking in this package are
57-
#' organized into several categories, each with its own documentation:
54+
#' @section PPC plotting functions: The plotting functions for posterior
55+
#' predictive checking in this package are organized into several categories,
56+
#' each with its own documentation:
5857
#' * [__Distributions__][PPC-distributions]: Histograms, kernel density
5958
#' estimates, boxplots, and other plots comparing the empirical distribution
6059
#' of the observed data `y` to the distributions of individual replicated
@@ -78,7 +77,6 @@
7877
#' multinomial outcomes.
7978
#' * [__LOO predictive checks__][PPC-loo]: PPC functions for predictive checks
8079
#' based on (approximate) leave-one-out (LOO) cross-validation.
81-
#' }
8280
#'
8381
#' @section Providing an interface for posterior predictive checking from another package:
8482
#'

man/MCMC-combos.Rd

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)