Is it possible to ensure that the posterior distribution of
Lobey these constraints?
Yep; this can be done for arbitrary constraints by just adding -Inf to the logjoint, i.e. putting
if ... # you're check as to whether the constraints are valid
Turing.@addlogprob! -Inf
# Do an early return since this entire sample will
# be rejected anyways.
return nothing
end
in your model. But this is a bad idea in a lot of cases, e.g. if you’re working with continuous variables and have equality constraints (like you’re wanting to do) since these will be satisfied with probability 0 ![]()
I am also not sure what effect the prior has on the posterior, i.e. should the prior of
Lalso satisfy the constraints?
Exactly. Whenever you can encode the constraints/symmetrics into your prior, do it:) In the particular example you mention you can for example drop the equality-constraint, and instead construct your L by using L12 in both the (1, 2) and the (2, 1) entry.
If indeed the example you posted is exactly what you want to do, i.e. you want a prior on a positive-definite matrix, then you always have the LKJ distribution + sampling the diagonal-terms separately, or even Wishart with parameters ensuring full-rank.