{"id":13401466,"url":"https://github.com/stan-dev/bayesplot","last_synced_at":"2025-05-15T15:05:22.504Z","repository":{"id":8690200,"uuid":"59324359","full_name":"stan-dev/bayesplot","owner":"stan-dev","description":"bayesplot R package for plotting Bayesian models","archived":false,"fork":false,"pushed_at":"2025-02-04T16:45:02.000Z","size":365001,"stargazers_count":436,"open_issues_count":59,"forks_count":83,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-03-31T19:09:20.549Z","etag":null,"topics":["bayesian","ggplot2","mcmc","pandoc","r-package","stan","statistical-graphics","visualization"],"latest_commit_sha":null,"homepage":"https://mc-stan.org/bayesplot","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stan-dev.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"stan-dev","custom":"https://mc-stan.org/support/"}},"created_at":"2016-05-20T20:28:56.000Z","updated_at":"2025-03-31T14:17:13.000Z","dependencies_parsed_at":"2022-08-07T04:16:42.830Z","dependency_job_id":"a8d15330-c636-4179-82a5-b7924976e621","html_url":"https://github.com/stan-dev/bayesplot","commit_stats":{"total_commits":1407,"total_committers":33,"mean_commits":42.63636363636363,"dds":0.2373845060412224,"last_synced_commit":"ce4f5d1a4f6ba75298af9bbc41b6136d5319f85c"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stan-dev%2Fbayesplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stan-dev%2Fbayesplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stan-dev%2Fbayesplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stan-dev%2Fbayesplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stan-dev","download_url":"https://codeload.github.com/stan-dev/bayesplot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247721898,"owners_count":20985084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian","ggplot2","mcmc","pandoc","r-package","stan","statistical-graphics","visualization"],"created_at":"2024-07-30T19:01:02.976Z","updated_at":"2025-04-07T20:09:56.966Z","avatar_url":"https://github.com/stan-dev.png","language":"R","readme":"# bayesplot \u003cimg src=\"man/figures/stanlogo.png\" align=\"right\" width=\"120\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/bayesplot?color=blue)](https://cran.r-project.org/web/packages/bayesplot)\n[![Downloads](https://cranlogs.r-pkg.org/badges/bayesplot?color=blue)](https://cran.rstudio.com/package=bayesplot)\n[![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)\n[![codecov](https://codecov.io/gh/stan-dev/bayesplot/branch/master/graph/badge.svg)](https://codecov.io/gh/stan-dev/bayesplot)\n\u003c!-- badges: end --\u003e\n\n### Overview\n\n**bayesplot** is an R package providing an extensive library of plotting\nfunctions for use after fitting Bayesian models (typically with MCMC). \nThe plots created by **bayesplot** are ggplot objects, which means that after \na plot is created it can be further customized using various functions from\nthe **ggplot2** package. \n\nCurrently **bayesplot** offers a variety of plots of posterior draws, \nvisual MCMC diagnostics, graphical posterior (or prior) predictive checking, \nand general plots of posterior (or prior) predictive distributions.\n\nThe idea behind **bayesplot** is not only to provide convenient functionality\nfor users, but also a common set of functions that can be easily used by\ndevelopers working on a variety of packages for Bayesian modeling, particularly\n(but not necessarily) those powered by [**RStan**](https://mc-stan.org/rstan).\n\n### Getting started \n\nIf you are just getting started with **bayesplot** we recommend starting with\nthe tutorial [vignettes](https://mc-stan.org/bayesplot/articles/index.html), \nthe examples throughout the package [documentation](https://mc-stan.org/bayesplot/reference/index.html), \nand the paper _Visualization in Bayesian workflow_:\n\n* Gabry J, Simpson D, Vehtari A, Betancourt M, Gelman A (2019). Visualization in Bayesian workflow. \n_J. R. Stat. Soc. A_, 182: 389-402. doi:10.1111/rssa.12378. \n([journal version](https://rss.onlinelibrary.wiley.com/doi/full/10.1111/rssa.12378),\n[arXiv preprint](https://arxiv.org/abs/1709.01449),\n[code on GitHub](https://github.com/jgabry/bayes-vis-paper))\n\n### Resources\n\n* [mc-stan.org/bayesplot](https://mc-stan.org/bayesplot) (online documentation, vignettes)\n* [Ask a question](https://discourse.mc-stan.org) (Stan Forums on Discourse)\n* [Open an issue](https://github.com/stan-dev/bayesplot/issues) (GitHub issues for bug reports, feature requests)\n\n### Contributing \n\nWe 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.\n\n### Installation\n\n* Install from CRAN:\n\n```r\ninstall.packages(\"bayesplot\")\n```\n\n* Install latest development version from GitHub (requires [devtools](https://github.com/hadley/devtools) package):\n\n```r\nif (!require(\"devtools\")) {\n  install.packages(\"devtools\")\n}\ndevtools::install_github(\"stan-dev/bayesplot\", dependencies = TRUE, build_vignettes = FALSE)\n```\n\nThis installation won't include the vignettes (they take some time to build), but all of the vignettes are \navailable online at [mc-stan.org/bayesplot/articles](https://mc-stan.org/bayesplot/articles/).\n\n\n### Examples\n\nSome quick examples using MCMC draws obtained from the [__rstanarm__](https://mc-stan.org/rstanarm) \nand [__rstan__](https://mc-stan.org/rstann) packages.\n\n```r\nlibrary(\"bayesplot\")\nlibrary(\"rstanarm\")\nlibrary(\"ggplot2\")\n\nfit \u003c- stan_glm(mpg ~ ., data = mtcars)\nposterior \u003c- as.matrix(fit)\n\nplot_title \u003c- ggtitle(\"Posterior distributions\",\n                      \"with medians and 80% intervals\")\nmcmc_areas(posterior, \n           pars = c(\"cyl\", \"drat\", \"am\", \"wt\"), \n           prob = 0.8) + plot_title\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/mcmc_areas-rstanarm.png width=50%/\u003e\n\n```r\ncolor_scheme_set(\"red\")\nppc_dens_overlay(y = fit$y, \n                 yrep = posterior_predict(fit, draws = 50))\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/ppc_dens_overlay-rstanarm.png width=50%/\u003e\n\n```r\n# also works nicely with piping\nlibrary(\"dplyr\")\ncolor_scheme_set(\"brightblue\")\nfit %\u003e% \n  posterior_predict(draws = 500) %\u003e%\n  ppc_stat_grouped(y = mtcars$mpg, \n                   group = mtcars$carb, \n                   stat = \"median\")\n\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/ppc_stat_grouped-rstanarm.png width=50%/\u003e\n\n```r\n# with rstan demo model\nlibrary(\"rstan\")\nfit2 \u003c- stan_demo(\"eight_schools\", warmup = 300, iter = 700)\nposterior2 \u003c- extract(fit2, inc_warmup = TRUE, permuted = FALSE)\n\ncolor_scheme_set(\"mix-blue-pink\")\np \u003c- mcmc_trace(posterior2,  pars = c(\"mu\", \"tau\"), n_warmup = 300,\n                facet_args = list(nrow = 2, labeller = label_parsed))\np + facet_text(size = 15)\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/mcmc_trace-rstan.png width=50% /\u003e\n\n```r\n# scatter plot also showing divergences\ncolor_scheme_set(\"darkgray\")\nmcmc_scatter(\n  as.matrix(fit2),\n  pars = c(\"tau\", \"theta[1]\"), \n  np = nuts_params(fit2), \n  np_style = scatter_style_np(div_color = \"green\", div_alpha = 0.8)\n)\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/mcmc_scatter-rstan.png width=50% /\u003e\n\n```r\ncolor_scheme_set(\"red\")\nnp \u003c- nuts_params(fit2)\nmcmc_nuts_energy(np) + ggtitle(\"NUTS Energy Diagnostic\")\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/mcmc_nuts_energy-rstan.png width=50% /\u003e\n\n```r\n# another example with rstanarm\ncolor_scheme_set(\"purple\")\n\nfit \u003c- stan_glmer(mpg ~ wt + (1|cyl), data = mtcars)\nppc_intervals(\n  y = mtcars$mpg,\n  yrep = posterior_predict(fit),\n  x = mtcars$wt,\n  prob = 0.5\n) +\n  labs(\n    x = \"Weight (1000 lbs)\",\n    y = \"MPG\",\n    title = \"50% posterior predictive intervals \\nvs observed miles per gallon\",\n    subtitle = \"by vehicle weight\"\n  ) +\n  panel_bg(fill = \"gray95\", color = NA) +\n  grid_lines(color = \"white\")\n```\n\n\u003cimg src=https://github.com/stan-dev/bayesplot/blob/master/images/ppc_intervals-rstanarm.png width=55% /\u003e\n","funding_links":["https://github.com/sponsors/stan-dev","https://mc-stan.org/support/"],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstan-dev%2Fbayesplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstan-dev%2Fbayesplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstan-dev%2Fbayesplot/lists"}