|
13 | 13 | #' @template args-facet_args |
14 | 14 | #' @param ... Currently ignored. |
15 | 15 | #' @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 |
19 | 19 | #' [ggplot2::geom_point()] to control the transparency of the points |
20 | 20 | #' for the chains not highlighted. |
21 | 21 | #' @param n_warmup An integer; the number of warmup iterations included in |
22 | 22 | #' `x`. The default is `n_warmup = 0`, i.e. to assume no warmup |
23 | 23 | #' iterations are included. If `n_warmup > 0` then the background for |
24 | 24 | #' iterations `1:n_warmup` is shaded gray. |
25 | 25 | #' @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 |
27 | 27 | #' iterations have been discarded from the traceplot. It cannot be specified |
28 | 28 | #' if `n_warmup` is also set to a positive value. |
29 | 29 | #' @param window An integer vector of length two specifying the limits of a |
30 | 30 | #' 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 |
40 | 39 | #' specify arguments controlling the appearance of tick marks representing |
41 | 40 | #' divergences (if the `np` argument is specified). |
42 | 41 | #' @param divergences Deprecated. Use the `np` argument instead. |
|
45 | 44 | #' |
46 | 45 | #' @section Plot Descriptions: |
47 | 46 | #' \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], |
50 | 49 | #' the `np` argument can be used to also show divergences on the trace plot. |
51 | 50 | #' } |
52 | | -#' \item{`mcmc_trace_highlight`}{ |
| 51 | +#' \item{`mcmc_trace_highlight()`}{ |
53 | 52 | #' Traces are plotted using points rather than lines and the opacity of all |
54 | 53 | #' chains but one (specified by the `highlight` argument) is reduced. |
55 | 54 | #' } |
@@ -192,7 +191,7 @@ mcmc_trace <- |
192 | 191 |
|
193 | 192 | #' @rdname MCMC-traces |
194 | 193 | #' @export |
195 | | -#' @param highlight For `mcmc_trace_highlight`, an integer specifying one |
| 194 | +#' @param highlight For `mcmc_trace_highlight()`, an integer specifying one |
196 | 195 | #' of the chains that will be more visible than the others in the plot. |
197 | 196 | mcmc_trace_highlight <- |
198 | 197 | function(x, |
@@ -227,11 +226,10 @@ mcmc_trace_highlight <- |
227 | 226 | #' @rdname MCMC-traces |
228 | 227 | #' @export |
229 | 228 | #' @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. |
235 | 233 | trace_style_np <- |
236 | 234 | function(div_color = "red", |
237 | 235 | div_size = 0.25, |
@@ -391,16 +389,17 @@ chain_colors <- function(n) { |
391 | 389 | } |
392 | 390 |
|
393 | 391 |
|
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 | +#' |
404 | 403 | #' @importFrom dplyr summarise group_by select |
405 | 404 | divergence_rug <- function(np, np_style, n_iter, n_chain) { |
406 | 405 | if (is.data.frame(np)) { |
|
0 commit comments