I want to evaluate the non-normalized posterior of a Turing model at some point in the parameter space.
The guide suggests the prob"..."
or logprob"..."
string macros for this, but it seems inconvenient if there’s more than a handful of parameters.
I have 7 parameters so it looks like this (please ignore the silly distributions in this MWE):
@model function gdemo(x, y)
s² ~ InverseGamma(2, 3)
m ~ Normal(0, sqrt(s²))
n ~ Normal(0, sqrt(s²))
p ~ Normal(0, sqrt(s²))
q ~ Normal(0, sqrt(s²))
r ~ Normal(0, sqrt(s²))
s ~ Normal(0, sqrt(s²))
x ~ Normal(m+n+p+q, sqrt(s²))
y ~ Normal(q+r+s, sqrt(s²))
end
x = 0.1
y = 0.2
m = gdemo()
params = (s²=0.01, m=0.0, n=0.0, p=0.0, q=0.0, r=0.0, s=0.0)
logprob"x=x, y=y, s²=params.s², m=params.m, n=params.n, p=params.p, q=params.q, r=params.r, s=params.s | model=m"
Is there a more convenient way to get this log-probability? Something like joint_logprob(m; x, y, params...)
?