Turing sampling from priors


I am migrating to Turing.jl from Stan. I am trying to understand the coding of this example, and was wondering if there is a way to generate samples from priors? Also, is there a way to include a generated quantities block (or function), similar to Stan, where we can use the posterior to compute various quantities of interest?

# Bayesian poisson regression (LR)
@model function poisson_regression(x, y, n, σ²)
    b0 ~ Normal(0, σ²)
    b1 ~ Normal(0, σ²)
    b2 ~ Normal(0, σ²)
    b3 ~ Normal(0, σ²)
    for i in 1:n
        theta = b0 + b1 * x[i, 1] + b2 * x[i, 2] + b3 * x[i, 3]
        y[i] ~ Poisson(exp(theta))


Regarding priors, see this.

Regarding generated quantities, you can see the code that I’m using here.
We are working making it easier to do so.

I hope this helps!

1 Like