https://github.com/epiforecasts/stanedit
Edit stan models from R
https://github.com/epiforecasts/stanedit
probabilistic-programming stan
Last synced: 8 months ago
JSON representation
Edit stan models from R
- Host: GitHub
- URL: https://github.com/epiforecasts/stanedit
- Owner: epiforecasts
- License: other
- Created: 2024-11-13T16:20:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-03T11:11:21.000Z (over 1 year ago)
- Last Synced: 2024-12-03T12:20:34.081Z (over 1 year ago)
- Topics: probabilistic-programming, stan
- Language: R
- Homepage: http://epiforecasts.io/stanedit/
- Size: 88.9 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
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 `` 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 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!