How to use fit models to create new data

I want to run simulations for my projects in order to determine sample size for future data collection and how different prior perform, for which I want to use models that I already fit.

Imagine I fit a model like this:

prior1 <- prior(normal(0,10), class = b) +
  prior(cauchy(0,2), class = sd)
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
            data = epilepsy, family = poisson(), prior = prior1)

The first thing I am wondering is how can I create a new fake dataset that would be generated with the estimated parameters where I can easily vary the amount of data (e.g. like patients in the example above).

The second thing that would be immensely useful is if I could selectively change parameters and then generate data. As an example I would love to create a dataset where all parameters are unchanged but zBase is set to zero.

Obviously, I could simply write-out the equation and plug the numbers in but that’s something I’d love to avoid because I would have to do this for each case manually.

If I understand correctly, isn’t what you want equivalent to generating predictions from your model and then restricting your number of draws to the sample sizes you want to consider?

2 Likes