-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
63 lines (43 loc) · 1.66 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
---
output: github_document
---
## Edit stan models using R
This package facilitates editing of stan model code using R. This includes adding/removing blocks, extracting variable names, and inserting/removing lines.
Development of this package was inspired by the `<bi_model>` class in the [rbi](https://github.com/sbfnk/rbi) package.
## Installation
The stable version of the package can be installed using
```{r eval=FALSE}
install.packages("stanedit", repos = "https://epiforecasts.r-universe.dev/")
```
The development version can be installed using `pak`
```{r eval=FALSE}
pak::pak("epiforecasts/stanedit")
```
## Example
First we load a stan model and prepare it for editing using the functionality in this package.
```{r}
library("stanedit")
model_file_name <- system.file(package = "stanedit", "regression.stan")
reg <- stanedit(filename = model_file_name)
reg
```
Let's say we want to add standard normal priors for alpha and beta.
We can do this using
```{r}
insert_lines(reg,
lines = c(
"alpha ~ std_normal();",
"beta ~ std_normal();"
),
at_end_of = "model"
)
```
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [all-contributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
<a href="https://github.com/epiforecasts/stanedit/commits?author=sbfnk">sbfnk</a>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->