Bijectors.jl icon indicating copy to clipboard operation
Bijectors.jl copied to clipboard

What to do with `CorrBijector` ?

Open harisorgn opened this issue 2 years ago • 1 comments

After #246, CorrBijector is no longer in use. This was the old bijector for LKJ which mapped a correlation matrix to a matrix of the same dimensions in unconstrained space (see https://mc-stan.org/docs/reference-manual/correlation-matrix-transform.html).

Shall we remove CorrBijector altogether or keep/adapt it for some other purpose (can't think of something right now) ?

harisorgn avatar Jun 12 '23 12:06 harisorgn

There's still a use-case for a bijector that is effectively F = cholesky(R) for correlation matrix R. Suppose one wants a parameter F because their model needs the Cholesky factorization, but they want to put a Normal(0.9, 0.01) prior on R[1, 2]. Then they would need something like

@model function demo(n)
    F ~ LKJCholesky(n, 1)  # uniform distribution on Matrix(F)
    Rmat, logJ = with_logabsdet_jacobian(inverse(CorrToCholeskyBijector()), F)
    R := Rmat  # track R
    Turing.@addlogprob! logJ + logpdf(Normal(0.9, 0.01), R[1, 2])
    # add the rest of the model using F
end

The current CorrBijector() is effectively VecCholeskyBijector() ∘ CorrToCholeskyBijector()

sethaxen avatar May 25 '24 08:05 sethaxen