forked from mjskay/ggdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
executable file
·106 lines (83 loc) · 4.4 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
output: github_document
---
```{r chunk_options, include=FALSE}
knitr::opts_chunk$set(
fig.path = "man/figures/README/"
)
if (capabilities("cairo")) {
knitr::opts_chunk$set(
dev.args = list(png = list(type = "cairo"))
)
}
```
# ggdist: Visualizations of distributions and uncertainty
[](https://github.com/mjskay/ggdist/actions)
[](https://codecov.io/github/mjskay/ggdist?branch=master)
[](https://cran.r-project.org/package=ggdist)

[](https://doi.org/10.5281/zenodo.3879620)

[ggdist](http://mjskay.github.io/ggdist/) is an R package that provides a flexible set of `ggplot2` geoms and stats designed
especially for visualizing distributions and uncertainty. It is designed for both
frequentist and Bayesian uncertainty visualization, taking the view that uncertainty
visualization can be unified through the perspective of distribution visualization:
for frequentist models, one visualizes confidence distributions or bootstrap distributions (see `vignette("freq-uncertainty-vis")`);
for Bayesian models, one visualizes probability distributions (see the [tidybayes](http://mjskay.github.io/tidybayes/)
package, which builds on top of `ggdist`).
The `geom_slabinterval()` / `stat_slabinterval()` / `stat_dist_slabinterval()` family (see `vignette("slabinterval")`) includes
point summaries and intervals, eye plots, half-eye plots, CCDF bar plots, gradient plots,
dotplots, and histograms:

The `geom_lineribbon()` / `stat_lineribbon()` / `stat_dist_lineribbon()` family makes it easy to visualize fit lines with an arbitrary
number of uncertainty bands:
```{r lineribbon, echo=FALSE, message=FALSE, warning=FALSE}
library(ggplot2)
library(dplyr)
library(tidyr)
library(ggdist)
library(broom)
m_mpg = lm(mpg ~ hp * cyl, data = mtcars)
mtcars %>%
group_by(cyl) %>%
expand(hp = seq(min(hp), max(hp), length.out = 101)) %>%
augment(m_mpg, newdata = ., se_fit = TRUE) %>%
ggplot(aes(x = hp, fill = ordered(cyl), color = ordered(cyl))) +
stat_dist_lineribbon(
aes(dist = "norm", arg1 = .fitted, arg2 = .se.fit),
alpha = 1/4
) +
geom_point(aes(y = mpg), data = mtcars) +
scale_fill_brewer(palette = "Set2") +
scale_color_brewer(palette = "Dark2") +
labs(
color = "cyl",
fill = "cyl",
y = "mpg"
) +
theme_ggdist()
```
All geoms in `ggdist` also have `stat_dist_` counterparts designed for visualizing analytical
distributions, which is particularly useful when visualizing uncertainty in frequentist
models (see `vignette("freq-uncertainty-vis")`) or when visualizing priors in a
Bayesian analysis.
The `ggdist` geoms and stats also form a core part of the [tidybayes](http://mjskay.github.io/tidybayes/) package (in fact,
they originally were part of `tidybayes`). For examples of the use of `ggdist` geoms and
stats for visualizing uncertainty in Bayesian models, see the vignettes in tidybayes, such as
`vignette("tidybayes", package = "tidybayes")` or `vignette("tidy-brms", package = "tidybayes")`.
## Installation
Once on CRAN, you can install the currently-released version from CRAN with this R
command:
```{r install, eval=FALSE}
install.packages("ggdist")
```
Alternatively, you can install the latest development version from GitHub with these R
commands:
```{r install_github, eval=FALSE}
install.packages("devtools")
devtools::install_github("mjskay/ggdist")
```
## Feedback, issues, and contributions
I welcome feedback, suggestions, issues, and contributions! Contact me at <mjskay@umich.edu>. If you have found a bug, please file it [here](https://github.com/mjskay/ggdist/issues/new) with minimal code to reproduce the issue. Pull requests should be filed against the [`dev`](https://github.com/mjskay/ggdist/tree/dev) branch.
## Citing `ggdist`
Matthew Kay (`r format(Sys.Date(), "%Y")`). _ggdist: Visualizations of Distributions and Uncertainty_. R package version `r getNamespaceVersion("ggdist")`, <https://mjskay.github.io/ggdist/>. DOI: [10.5281/zenodo.3879620](https://doi.org/10.5281/zenodo.3879620).