# Prior predictive distribution as in posterior_predict/epred

Hello,

Is there a way to have a prior predictive distribution with the same output structure as posterior_predict/epred. I was only able to extract the parameters prior, not the output one.

Thanks

Hi,

don’t know if this will help you but in brms one can always sample with sample_prior="only", and thus get a “posterior” which consists of values sampled only from the priors.

I’m a bit unsure what you mean by “not the output one.”

1 Like

Sorry, it was unclear, I meant the prior distribution of the outcome of the model, that is solving the model using the prior values for the parameters, which is what posterior_predict/epred does.

I might misunderstand you but,

run with brms (notice I only sample from the priors using sample_prior="only")

library(rethinking)
data(chimpanzees)
d <- chimpanzees
library(brms)
rm(chimpanzees)

m <-
brm(data = d, family = binomial,
pulled_left | trials(1) ~ 1 + prosoc_left,
prior = c(prior(normal(0, 10), class = Intercept),
prior(normal(0, 10), class = b)),
sample_prior = "only")

pl <- posterior_linpred(m)
pe <- posterior_epred(m)
pp <- posterior_predict(m)


Each variable now contains 504 rows and 4000 cols. So the model looks like this:

\mathrm{pulled\_left}_i \sim \mathrm{Binomial}(1,p_i)\\ p_i = \mathrm{inv\_logit}(q_i)\\ q_i = \alpha + \beta_p \cdot \mathrm{prosoc\_left}_i \\ \alpha \sim \mathrm{Normal}(0, 10)\\ \beta_p \sim \mathrm{Normal}(0, 10)

then,

• pl has posterior draws of q
• pe has draws of p, i.e., applying the link function, in this case inv_logit()
• pp has draws from \mathrm{Binomial}(1,p), i.e., the data is on the outcome scale (0/1). (Binomial has no dispersion).
> table(pp)
pp
0       1
1006469 1009531


See here for the example I use translated by @Solomon from McElreath’s book:

and here where @jonah explains it very nicely:

1 Like

Thanks! I actually solved too using brms since rstanarm seemingly doesn’t allow this!