Skip to content

Accessing traced variables within a @gen macro #553

Answered by ztangent
sdwfrost asked this question in Q&A
Discussion options

You must be logged in to vote

You can do assignment in addition to sampling. The ~ syntax in a @gen function is just syntactic sugar (as explained here: https://www.gen.dev/docs/dev/ref/modeling/dml/#Tilde-syntax)

For your example, you can do:

# Priors
beta_mean ~ uniform(0.0, 1.0)
beta_sd ~ uniform(0.0, 0.1)
beta = zeros(nsteps)
for i in 1:nsteps
      beta[i] = {(:βi,i)} ~ normal(beta_mean, beta_sd)
 end

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sdwfrost
Comment options

Answer selected by sdwfrost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants