Over the last few weeks I’ve been working on a package called rgreta which aims to provide simple simulation of greta models. I have just pushed the project to github and you can find it here.
rgreta provides a new function simulate which will simulate the output of a greta model by sampling parameters and running operations.
Example usage (from the README):
We define a simple greta model:
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 as is:
devtools::install_github("Voltemand/rgreta") library(rgreta) simulations <- simulate(m) head(simulations)
or we can specify model parameters
simulations <- simulate(m, list(int = 1, coef = 1, sd = 1) head(simulations)
This package is very much in the essential feature adding/bug crushing stage so I’d love to hear about any bugs or ideas.
The major limitation of the package at the moment is that it only supports sampling from Normal and Cauchy distributions and running addition and multiplication operations. If there is interest in the package however it should be very easy to add more.
All the best,