An open API service indexing awesome lists of open source software.

https://github.com/jeffreypullin/rgreta

Simple simulation of greta models
https://github.com/jeffreypullin/rgreta

Last synced: 10 months ago
JSON representation

Simple simulation of greta models

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# rgreta

**rgreta** provides support for simple simulation of models defined in the
**greta** modelling language/R package

## Usage

Define a simple example greta model:
```{r, message=FALSE}
library(greta)

int <- normal(0, 10)
coef <- normal(0, 10)
sd <- cauchy(0, 3, truncation = c(0, Inf))

mu <- int + coef * attitude$complaints

distribution(attitude$rating) <- normal(mu, sd)

m <- model(int, coef, sd)
```

We can then simulate from the model:
```{r, message=FALSE}
library(rgreta)
simulations <- simulate(m)
head(simulations)
```

Or we can simulate setting parameters to certain values
```{r}
simulations <- simulate(m, list(int = 1, coef = 1, sd = 1))
head(simulations)
```

## Install
```{r, eval=FALSE}
devtools::install_github("Voltemand/rgreta")
```

## TODO

**rgreta** is very much still a work in progress. The current feature/idea list
is:

* Support for more distibutions and operations - currently rgreta only supports
the normal and cauchy distributions and addition and multiplication operations
* Seed passing
* A way to pass simulated data back to models
* Support for tensorflow probability distibutions samplers
* Returning of simulated parameters