Skip to content

Commit

Permalink
add release_questions() helper
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
jgabry committed Jun 1, 2020
1 parent d9b35f2 commit 184c5a9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ images/*
book/*
docs/*
Rplots.pdf
tests/figs/*
10 changes: 10 additions & 0 deletions R/bayesplot-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@
#' }
#'
NULL


# internal ----------------------------------------------------------------

# release reminders (for devtools)
release_questions <- function() { # nocov start
c(
"Have you reduced the size of the vignettes for CRAN?",
)
} # nocov end
27 changes: 25 additions & 2 deletions vignettes/plotting-mcmc-draws.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,18 @@ transform the draws in advance or use the `transformations` argument.

```{r, mcmc_hist-transform, message=FALSE}
color_scheme_set("blue")
mcmc_hist(posterior, pars = c("wt", "sigma"),
mcmc_hist(posterior, pars = c("wt", "sigma"),
transformations = list("sigma" = "log"))
```

<!-- ```{r, mcmc_hist-transform, message=FALSE, eval=FALSE} -->
<!-- # not evaluated to reduce vignette size for CRAN -->
<!-- # full version available at mc-stan.org/bayesplot/articles -->
<!-- color_scheme_set("blue") -->
<!-- mcmc_hist(posterior, pars = c("wt", "sigma"), -->
<!-- transformations = list("sigma" = "log")) -->
<!-- ``` -->

Most of the other functions for plotting MCMC draws also have a
`transformations` argument.

Expand Down Expand Up @@ -267,6 +275,14 @@ mcmc_pairs(posterior, pars = c("(Intercept)", "wt", "sigma"),
off_diag_args = list(size = 1.5))
```

<!-- ```{r, mcmc_pairs, message=FALSE, eval=FALSE} -->
<!-- # not evaluated to reduce vignette size for CRAN -->
<!-- # full version available at mc-stan.org/bayesplot/articles -->
<!-- color_scheme_set("pink") -->
<!-- mcmc_pairs(posterior, pars = c("(Intercept)", "wt", "sigma"), -->
<!-- off_diag_args = list(size = 1.5)) -->
<!-- ``` -->

The univariate marginal posteriors are shown along the diagonal as histograms,
but this can be changed to densities by setting `diag_fun="dens"`. Bivariate
plots are displayed above and below the diagonal as scatterplots, but it is also
Expand Down Expand Up @@ -325,11 +341,18 @@ by side, and `strip.position="left"` moves the facet labels to the y-axis
The [`"viridis"` color scheme](https://CRAN.R-project.org/package=viridis) is
also useful for trace plots because it is comprised of very distinct colors:

```{r, viridis-scheme}
```{r, viridis-scheme, eval=FALSE}
color_scheme_set("viridis")
mcmc_trace(posterior, pars = "(Intercept)")
```

<!-- ```{r, viridis-scheme, eval=FALSE} -->
<!-- # not evaluated to reduce vignette size for CRAN -->
<!-- # full version available at mc-stan.org/bayesplot/articles -->
<!-- color_scheme_set("viridis") -->
<!-- mcmc_trace(posterior, pars = "(Intercept)") -->
<!-- ``` -->

#### mcmc_trace_highlight

The `mcmc_trace_highlight` function uses points instead of lines and reduces the
Expand Down
33 changes: 23 additions & 10 deletions vignettes/visual-mcmc-diagnostics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,27 @@ visualizations.

#### mcmc_parcoord

The parallel coordinates plot (`mcmc_parcoord`) is probably the first plot to
have look at if you have no idea, where the divergences in your model might be
coming from. This function works in general without including information about
the divergences, but if the optional `np` argument is used to pass NUTS
parameter information, then divergences will be colored in the plot (by default
in red).
The `mcmc_parcoord` plot shows one line per iteration, connecting the parameter
values at this iteration. This lets you see global patterns in the divergences.

This function works in general without including information about the
divergences, but if the optional `np` argument is used to pass NUTS parameter
information, then divergences will be colored in the plot (by default in red).

```{r, mcmc_parcoord-1}
color_scheme_set("darkgray")
mcmc_parcoord(posterior_cp, np = np_cp)
```

The `mcmc_parcoord` plot shows one line per iteration, connecting the parameter
values at this iteration. This lets you see any global patterns in the
divergences. Here, you may notice that divergences in the centered

<!-- ```{r, mcmc_parcoord-1, eval=FALSE} -->
<!-- # not evaluated to reduce vignette size for CRAN -->
<!-- # full version available at mc-stan.org/bayesplot/articles -->
<!-- color_scheme_set("darkgray") -->
<!-- mcmc_parcoord(posterior_cp, np = np_cp) -->
<!-- ``` -->

Here, you may notice that divergences in the centered
parameterization happen exclusively when `tau`, the hierarchical standard
deviation, goes near zero and the values of the `theta`s are essentially fixed.
This makes `tau` immediately suspect.
Expand All @@ -289,10 +295,17 @@ Let's look at how `tau` interacts with other variables, using only one of the
`theta`s to keep the plot readable:

```{r, mcmc_pairs}
mcmc_pairs(posterior_cp, np = np_cp, pars = c("mu","tau","theta[1]"),
mcmc_pairs(posterior_cp, np = np_cp, pars = c("mu","tau","theta[1]"),
off_diag_args = list(size = 0.75))
```

<!-- ```{r, mcmc_pairs, eval=FALSE} -->
<!-- # not evaluated to reduce vignette size for CRAN -->
<!-- # full version available at mc-stan.org/bayesplot/articles -->
<!-- mcmc_pairs(posterior_cp, np = np_cp, pars = c("mu","tau","theta[1]"), -->
<!-- off_diag_args = list(size = 0.75)) -->
<!-- ``` -->

Note that each bivariate plot is present twice -- by default each of those
contain half of the chains, so you also get to see if the chains produced
similar results (see the documentation for the `condition` argument for
Expand Down

0 comments on commit 184c5a9

Please sign in to comment.