-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.Rmd
166 lines (149 loc) · 5.39 KB
/
index.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
title: Bayesian Basics
author: |
<span class="noem">Michael Clark</span> <br>
[m-clark.github.io](https://m-clark.github.io/)
# date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output:
bookdown::gitbook:
anchor_sections: FALSE
documentclass: book
bibliography: ['packages.bib', 'BayesBasics.bib']
biblio-style: apalike
always_allow_html: true
link-citations: yes
github-repo: 'm-clark/bayesian-basics/'
description: "This document provides an introduction to Bayesian data analysis. It is conceptual in nature, but uses the probabilistic programming language Stan for demonstration (and its implementation in R via rstan). From elementary examples, guidance is provided for data preparation, efficient modeling, diagnostics, and more."
cover-image: 'img/nineteeneightyR.png'
favicon: 'img/R.ico'
url: 'https\://m-clark.github.io/bayesian-basics/' # the \: is required or you'll get text in the title/toc area
nocite: |
@kruschke2014doing, @gelman_arm, @mcgrayne_theory_2012, @gelmanPardoe2006, @carpenter2017stan,
@gelmanHwangVehtari, @gelmanVehtariWAIC, @mcelreath2020, @vehtari2017practical, @vehtari2015pareto
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE,
error = FALSE,
comment = NA,
R.options = list(width = 220),
# code
dev.args = list(bg = 'transparent'),
dev = 'svg',
fig.align = 'center',
# viz
cache.rebuild = FALSE,
cache = TRUE
)
library(tidyverse)
# create a theme
theme_clean <- function (
font_size = 12,
font_family = "",
center_axis_labels = FALSE
) {
if (center_axis_labels) {
haxis_just_x <- 0.5
vaxis_just_y <- 0.5
v_rotation_x <- 0
v_rotation_y <- 0
}
else {
haxis_just_x <- 0
vaxis_just_y <- 1
v_rotation_x <- 0
v_rotation_y <- 0
}
ggplot2::theme(
text = ggplot2::element_text(
family = font_family,
face = "plain",
color = "gray30",
size = font_size,
hjust = 0.5,
vjust = 0.5,
angle = 0,
lineheight = 0.9,
margin = ggplot2::margin(),
debug = FALSE
),
axis.title.x = ggplot2::element_text(
hjust = haxis_just_x,
angle = v_rotation_x,
size = 0.8 * font_size
),
axis.title.y = ggplot2::element_text(
vjust = vaxis_just_y,
hjust = 0,
angle = v_rotation_y,
size = 0.8 * font_size
),
axis.ticks = ggplot2::element_line(color = "gray30"),
title = ggplot2::element_text(color = "gray30", size = font_size * 1.25),
plot.subtitle = ggplot2::element_text(color = "gray30", size = font_size * .75, hjust = 0),
plot.caption = ggplot2::element_text(color = "gray30", size = font_size * .5, hjust = 0),
legend.position = 'bottom',
legend.key = ggplot2::element_rect(fill = "transparent", color = NA),
legend.background = ggplot2::element_rect(fill = "transparent", color = NA),
legend.title = ggplot2::element_blank(),
panel.background = ggplot2::element_blank(),
panel.grid = ggplot2::element_blank(),
strip.background = ggplot2::element_blank(),
plot.background = ggplot2::element_rect(fill = "transparent", color = NA),
)
}
# set the theme as default
theme_set(theme_clean())
# set other point/line default colors; in most cases, we can use the color from
# default discrete scale for more consistency across plots.
# paletteer::palettes_d$colorblindr$OkabeIto
update_geom_defaults('vline', list(color = 'gray25', alpha = .25)) # vlines and hlines are typically not attention grabbers so set alpha
update_geom_defaults('hline', list(color = 'gray25', alpha = .25)) # usually a zero marker
update_geom_defaults('point', list(color = '#E69F00', alpha = .5)) # alpha as usually there are many points
update_geom_defaults('smooth', list(color = '#56B4E9', alpha = .15))
update_geom_defaults('line', list(color = '#56B4E9', alpha = .5))
update_geom_defaults('bar', list(color = '#E69F00', fill = '#E69F00'))
update_geom_defaults('col', list(color = '#E69F00', fill = '#E69F00'))
update_geom_defaults('dotplot', list(color = '#E69F00', fill = '#E69F00'))
# use colorblind safe colors for categories; if you supply a continuous value to
# color you'll get an error, but you just have to use `myplot +
# scale_color_continous()` or whatever to override this; likewise you can always
# override this scale for categorical schemes if desired also. Note that this
# will apply for both color and fill, which is usually what we want.
ggplot <- function(...) ggplot2::ggplot(...) +
# okabe ito colorblind safe scheme
scale_color_manual(
values = c(
'#E69F00',
'#56B4E9',
'#009E73',
'#F0E442',
'#0072B2',
'#D55E00',
'#CC79A7',
'#999999'
),
drop = FALSE,
aesthetics = c('color', 'fill')
)
# automatically create a bib database for R packages
knitr::write_bib(c(.packages(), 'bookdown', 'knitr', 'rmarkdown'), 'packages.bib')
```
```{r load_packages, echo=FALSE, cache=FALSE}
library(tidyverse)
library(lazerhawk)
library(pander)
library(visibly)
library(kableExtra)
```
##### {-}
```{r rimg, fig.align='center', out.width=200, echo=FALSE, cache=FALSE}
knitr::include_graphics('img/198R.png', dpi = NA)
```
```{r ccimg, fig.align='center', out.width=0, fig.show='hide', echo=FALSE}
knitr::include_graphics('img/mc_logo.png', dpi = NA)
knitr::include_graphics('img/mc_sunset_2.png', dpi = NA)
```