A better unit vector

I’m not sure if I understand you correctly. So maybe I just misunderstood your post you when I wrote the following answers.

I assume you’re talking about the “jacobian correction” on the sphere radius.
It doesn’t need to be correct, as it is orthogonal to all model parameters. It can be left out or modified. The sphere radius prior can (and should) be freely chosen to optimize sampler performance and robustness. That is why in that thread we have been discussing a variety of different terms for this purpose. These do not all include a jacobian correction. Still, I’d be interested to hear what you think the correct jacobian correction would be.

I don’t understand this sentence (has been a while since I last thought about this topic). Is there another way to say this?

It is my understanding that “setting it equal to 1” would re-introduce the problems which unit-vectors are supposed to solve in the first place. As far as I can tell it is necessary to have an “extra-dimension” to solve them. That is, unless you modify the sampler internally to “teleport” the particle to the sphere surface at each leapfrog step and set the momentum orthogonal to the sphere surface to zero. If that is what you mean then I agree.

That’s the (or at least “a”) reason for having unit-vectors.
For example when using a 0 to 2pi parameterisation issues arise with posteriors which have meaningful mass on both sides of the boundary, but negligible mass away from it. If 0 and 2π are not neighbours then the result is a strongly bimodal distribution, which leads to sampling problems.

I can’t follow you there. In the previous paragraph (which you seem to refer to in the quoted sentence) you were talking about a 0 to 2pi boundary rather then 0 to pi.

I dont understand the example Stan code. But maybe I’m missing something. I haven’t tried to run your code to check. Why is there a target+= statement in the transformed parameters block (hidden in a function)? I thought that isn’t allowed. Does it have any effect? I also don’t understand the purpose of that target+= statement. The code looks to me as if this target statement had an effect the model wouldn’t give the correct results, since (it sems to me as if) it essentially defines an (unwanted) prior on theta. Did you try fitting the model to datasets with phase angles other than pi/2? E.g. a phase angle of -pi/2 (which I would think doesn’t work because you restricted theta to 0 to pi).
I’ll stop here, as I’m probably missing something basic. I haven’t looked at the second stan model yet.

2 Likes