Is it more efficient to reparametrize to a beta if I'm estimating a 2-dimensional simplexe?

They’re pretty much identical if you look at how a 2-dimensional simplex gets implemented.

  1. You don’t need to write down dirichlet([1, ..., 1]) or beta(1, 1) explicitly because they’re uniform and don’t add anything other than a constant to the log density.

  2. Stan’s underlying simplex implementation (see the transforms chapter of the reference manual), does exactly what you’ve coded—give delta[1] a uniform(0, 1) distribution and then set delta[2] = 1 - delta[1].

Also, you can just try both and see if there’s a speed difference you can detect (you can’t define beta the way you did—it needs two real-valued arguments, not a vector argument). It’s often hard to figure out what the C++ optimizer is going to do and sometimes things that look like the same code can have different performance. I don’t expect that here though.

1 Like