diff --git a/.Rbuildignore b/.Rbuildignore index a91bcc13..031ffa55 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,7 +3,7 @@ ^.*\.Rproj$ ^\.Rproj\.user$ LICENSE -^\.travis\.yml$ +^\_pkgdown\.yml$ ^README\.md$ .gitignore .git/* diff --git a/.github/workflows/pkgdown.yml b/.github/workflows/pkgdown.yml new file mode 100644 index 00000000..dc9cce3f --- /dev/null +++ b/.github/workflows/pkgdown.yml @@ -0,0 +1,55 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + # build dev site on merged pushes + push: + branches: [main, master] + # build full site on releases + release: + types: [published] + workflow_dispatch: + +name: pkgdown.yaml + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + cancel-in-progress: true + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::., any::withr, stan-dev/pkgdown-config + + - name: Build site + run: | + withr::with_envvar( + c("NOT_CRAN" = "true"), # this should already be set by setup-r@v2? keeping because vignettes don't build otherwise + pkgdown::build_site_github_pages( + lazy = FALSE, # change to TRUE if runner times out. + run_dont_run = TRUE, + new_process = TRUE + ) + ) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + uses: JamesIves/github-pages-deploy-action@v4.5.0 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/R/bayesplot-package.R b/R/bayesplot-package.R index a2d4531d..4eb23955 100644 --- a/R/bayesplot-package.R +++ b/R/bayesplot-package.R @@ -8,7 +8,7 @@ #' #' @description #' \if{html}{ -#' \figure{stanlogo.png}{options: width="50" alt="mc-stan.org"} +#' \figure{logo.svg}{options: width="50" alt="mc-stan.org"} #' } #' *Stan Development Team* #' diff --git a/README.md b/README.md index b9b878d6..db75f239 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# bayesplot +# bayesplot [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/bayesplot?color=blue)](https://cran.r-project.org/web/packages/bayesplot) [![Downloads](https://cranlogs.r-pkg.org/badges/bayesplot?color=blue)](https://cran.rstudio.com/package=bayesplot) -[![R-CMD-check](https://github.com/stan-dev/bayesplot/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/stan-dev/bayesplot/actions/workflows/R-CMD-check.yaml) +[![R-CMD-check](https://github.com/stan-dev/bayesplot/actions/workflows/R-CMD-check.yaml/badge.svg)](https://raw.githubusercontent.com/stan-dev/bayesplot/actions/workflows/R-CMD-check.yaml) [![codecov](https://codecov.io/gh/stan-dev/bayesplot/branch/master/graph/badge.svg)](https://codecov.io/gh/stan-dev/bayesplot) @@ -35,17 +35,17 @@ and the paper _Visualization in Bayesian workflow_: _J. R. Stat. Soc. A_, 182: 389-402. doi:10.1111/rssa.12378. ([journal version](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/rssa.12378), [arXiv preprint](https://arxiv.org/abs/1709.01449), -[code on GitHub](https://github.com/jgabry/bayes-vis-paper)) +[code on GitHub](https://raw.githubusercontent.com/jgabry/bayes-vis-paper)) ### Resources * [mc-stan.org/bayesplot](https://mc-stan.org/bayesplot) (online documentation, vignettes) * [Ask a question](https://discourse.mc-stan.org) (Stan Forums on Discourse) -* [Open an issue](https://github.com/stan-dev/bayesplot/issues) (GitHub issues for bug reports, feature requests) +* [Open an issue](https://raw.githubusercontent.com/stan-dev/bayesplot/issues) (GitHub issues for bug reports, feature requests) ### Contributing -We are always looking for new contributors! See [CONTRIBUTING.md](https://github.com/stan-dev/bayesplot/blob/master/.github/CONTRIBUTING.md) for details and/or reach out via the issue tracker. +We are always looking for new contributors! See [CONTRIBUTING.md](https://raw.githubusercontent.com/stan-dev/bayesplot/master/.github/CONTRIBUTING.md) for details and/or reach out via the issue tracker. ### Installation @@ -55,7 +55,7 @@ We are always looking for new contributors! See [CONTRIBUTING.md](https://github install.packages("bayesplot") ``` -* Install latest development version from GitHub (requires [devtools](https://github.com/hadley/devtools) package): +* Install latest development version from GitHub (requires [devtools](https://raw.githubusercontent.com/hadley/devtools) package): ```r if (!require("devtools")) { @@ -88,7 +88,7 @@ mcmc_areas(posterior, prob = 0.8) + plot_title ``` - + ```r color_scheme_set("red") @@ -96,7 +96,7 @@ ppc_dens_overlay(y = fit$y, yrep = posterior_predict(fit, draws = 50)) ``` - + ```r # also works nicely with piping @@ -110,7 +110,7 @@ fit %>% ``` - + ```r # with rstan demo model @@ -124,7 +124,7 @@ p <- mcmc_trace(posterior2, pars = c("mu", "tau"), n_warmup = 300, p + facet_text(size = 15) ``` - + ```r # scatter plot also showing divergences @@ -137,7 +137,7 @@ mcmc_scatter( ) ``` - + ```r color_scheme_set("red") @@ -145,7 +145,7 @@ np <- nuts_params(fit2) mcmc_nuts_energy(np) + ggtitle("NUTS Energy Diagnostic") ``` - + ```r # another example with rstanarm @@ -168,4 +168,4 @@ ppc_intervals( grid_lines(color = "white") ``` - + diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 00000000..4388eb8c --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,131 @@ +url: https://mc-stan.org/bayesplot + +development: + mode: auto + +destination: "." + +template: + package: pkgdownconfig + +navbar: + title: "bayesplot" + + structure: + left: [home, vignettes, functions, news, pkgs, stan] + right: [search, bluesky, forum, github, lightswitch] + + components: + pkgs: + text: Other Packages + menu: + - text: cmdstanr + href: https://mc-stan.org/cmdstanr + - text: loo + href: https://mc-stan.org/loo + - text: posterior + href: https://mc-stan.org/posterior + - text: projpred + href: https://mc-stan.org/projpred + - text: rstan + href: https://mc-stan.org/rstan + - text: rstanarm + href: https://mc-stan.org/rstanarm + - text: rstantools + href: https://mc-stan.org/rstantools + - text: shinystan + href: https://mc-stan.org/shinystan + +articles: + - title: "Getting Started" + desc: > + These vignettes provide an introduction to visualizing MCMC draws and + diagnostics and performing graphical posterior predictive checks using + the **bayesplot** package. + contents: + - plotting-mcmc-draws + - visual-mcmc-diagnostics + - graphical-ppcs + +reference: + - title: "Overview" + desc: > + Package overview + contents: + - bayesplot-package + - title: "Aesthetics" + desc: > + Functions for setting the color scheme and ggplot theme used + by **bayesplot**. (Also see the separate **ggplot helpers** section + below.) + contents: + - bayesplot-colors + - bayesplot_theme_get + - theme_default + - title: "PPC" + desc: > + Functions for carrying out a wide variety of graphical model checks + based on comparing observed data to draws from the posterior or prior + predictive distribution. + contents: + - PPC-overview + - starts_with("ppc") + - pp_check + - title: "PPD" + desc: > + Functions for creating graphical displays of simulated data from the + posterior or prior predictive distribution (PPD). These plots are essentially + the same as the corresponding PPC plots but without comparing to any observed + data. + contents: + - PPD-overview + - starts_with("ppd") + - title: "MCMC" + desc: > + Functions for creating plots of MCMC draws of model parameters and + general MCMC diagnostics. + contents: + - MCMC-overview + - MCMC-diagnostics + - MCMC-distributions + - MCMC-intervals + - MCMC-recover + - MCMC-scatterplots + - MCMC-parcoord + - MCMC-traces + - MCMC-combos + - title: "HMC/NUTS diagnostics" + desc: > + Functions for plotting diagnostics specific to Hamiltonian Monte Carlo (HMC) + and the No-U-Turn Sampler (NUTS). Some of the general MCMC plotting functions + (`mcmc_parcoord()`, `mcmc_pairs()`, `mcmc_scatter()`, `mcmc_trace()`) can also + show HMC/NUTS diagnostic information if optional arguments are specified, + but the special functions below are _only_ intended for use with HMC/NUTS. + contents: + - MCMC-nuts + - title: "Tidy parameter selection for MCMC plots" + desc: > + Helper functions for tidy parameter selection and examples of using + **bayesplot** with [**dplyr**](https://dplyr.tidyverse.org/). + contents: + - tidy-params + - title: "ggplot helpers" + desc: > + Convenience functions for arranging multiple plots, adding features + to plots, and shortcuts for modifying individual ggplot theme elements. + contents: + - bayesplot_grid + - bayesplot-helpers + - title: "Extractors" + desc: > + Functions extracting various quantities needed for plotting from different + types of fitted model objects. + contents: + - bayesplot-extractors + - title: "Miscellaneous" + desc: > + Functions for generating data for examples and listing available + plotting functions. + contents: + - example-data + - available_ppc diff --git a/man/bayesplot-package.Rd b/man/bayesplot-package.Rd index ae59ee0e..5ef89271 100644 --- a/man/bayesplot-package.Rd +++ b/man/bayesplot-package.Rd @@ -7,7 +7,7 @@ \title{\strong{bayesplot}: Plotting for Bayesian Models} \description{ \if{html}{ - \figure{stanlogo.png}{options: width="50" alt="mc-stan.org"} + \figure{logo.svg}{options: width="50" alt="mc-stan.org"} } \emph{Stan Development Team} diff --git a/man/figures/logo.svg b/man/figures/logo.svg index b4c09fc5..496f0402 100644 --- a/man/figures/logo.svg +++ b/man/figures/logo.svg @@ -1,96 +1 @@ - - - - + \ No newline at end of file diff --git a/man/figures/stanlogo.png b/man/figures/stanlogo.png deleted file mode 100644 index 4a4f06aa..00000000 Binary files a/man/figures/stanlogo.png and /dev/null differ diff --git a/vignettes/graphical-ppcs.Rmd b/vignettes/graphical-ppcs.Rmd index 5e866dd4..db649f42 100644 --- a/vignettes/graphical-ppcs.Rmd +++ b/vignettes/graphical-ppcs.Rmd @@ -19,6 +19,7 @@ vignette: > ```{r pkgs, include=FALSE} library("ggplot2") library("rstanarm") +bayesplot_theme_set() set.seed(840) ``` diff --git a/vignettes/plotting-mcmc-draws.Rmd b/vignettes/plotting-mcmc-draws.Rmd index 38aa1081..0ed21f62 100644 --- a/vignettes/plotting-mcmc-draws.Rmd +++ b/vignettes/plotting-mcmc-draws.Rmd @@ -19,6 +19,7 @@ vignette: > ```{r pkgs, include=FALSE} library("ggplot2") library("rstanarm") +bayesplot_theme_set() ```