-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathindex.Rmd
47 lines (35 loc) · 1.02 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
```{r setup, include=FALSE}
knitr::opts_chunk$set(cache = TRUE,
fig.path = "man/figures/")
set.seed(2018-02-17)
```
<div class="row">
<div class="col-md-6">
Here's a Bayesian linear regression model for the `iris` data using greta:
```{r, highlight = FALSE}
x <- iris$Petal.Length
y <- iris$Sepal.Length
```
```{r, highlight = FALSE, message = FALSE}
library(greta)
int <- normal(0, 5)
coef <- normal(0, 3)
sd <- lognormal(0, 3)
mean <- int + coef * x
distribution(y) <- normal(mean, sd)
```
```{r, highlight = FALSE}
m <- model(int, coef, sd)
```
</div>
<div class="col-md-6">
```{r, highlight = FALSE, eval = FALSE}
draws <- mcmc(m, n_samples = 1000, chains = 4)
bayesplot::mcmc_trace(draws)
```
```{r vis, echo = FALSE, eval = TRUE, results = "hide", message = FALSE, fig.height = 3.8, fig.width = 5.5, fig.align = "center"}
draws <- mcmc(m, n_samples = 1000, chains = 4)
bayesplot::mcmc_trace(draws, facet_args = list(nrow = 3, ncol = 1)) + ggplot2::theme_minimal()
```
</div>
</div>