reparametrizing a half-cauchy

312 views
Skip to first unread message

Ted Papalex

unread,
Mar 24, 2016, 5:30:22 PM3/24/16
to Stan users mailing list
Quick sanity check; I want to replace the uniform prior on a variance parameter with a half cauchy, as suggested in the manual. I'm using:

real<lower=0> sigma; 
...
sigma ~ cauchy(0, scale) //scale is an input to the program

The manual also suggests I should reparametrize the cauchy to avoid sampling problems:

real <lower=-pi()/2, upper=pi()/2> sigma_unif;
...
real sigma;
sigma <- 0 + scale * tan(sigma_unif);
....
sigma_unif ~ uniform(-pi()/2, pi()/2)) //not necessary

Of course this is the parametrization for a full, not half, cauchy, which is inappropriate for a scale parameter. Is the solution to set the lower limit of sigma_unif to 0 instead of pi/2? That produces the desire half cauchy right? 




Andrew Gelman

unread,
Mar 24, 2016, 5:33:23 PM3/24/16
to stan-...@googlegroups.com
Hi, just a quick comment which is that you could use something like a t_4 which could behave more reasonably.
(My bad for suggesting the Cauchy in the first place, I guess!)
A

--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Carpenter

unread,
Mar 24, 2016, 5:39:59 PM3/24/16
to stan-...@googlegroups.com
Andrew, could you take a stab at updating your prior choice
wiki:

https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations

- Bob

Bob Carpenter

unread,
Mar 24, 2016, 5:42:00 PM3/24/16
to stan-...@googlegroups.com
You shouldn't need to reparameterize in this case, but
yes, that'd be the right way to do it (though don't use
(0 + x) as it's just wasted arithmetic).

As a general piece of advice, get things working first,
then optimize if they aren't fast enough.

- Bob

> On Mar 24, 2016, at 5:34 PM, Andrew Gelman <gel...@stat.columbia.edu> wrote:
>

Ben Goodrich

unread,
Mar 24, 2016, 5:50:55 PM3/24/16
to Stan users mailing list
On Thursday, March 24, 2016 at 5:30:22 PM UTC-4, Ted Papalex wrote:
Of course this is the parametrization for a full, not half, cauchy, which is inappropriate for a scale parameter. Is the solution to set the lower limit of sigma_unif to 0 instead of pi/2? That produces the desire half cauchy right? 

Yes, although desiring the half-cauchy is now considered unfashionable.
 

Ted Papalex

unread,
Mar 24, 2016, 6:53:25 PM3/24/16
to Stan users mailing list
Thanks for the replies! 

I guess I can see the point in not wanting the particularly long tail, which actually makes sense given that I'm using logistic regression, and large variance won't make a difference inside the inv logit. That being said, in my application there will be usually be a large number of groups (30-100) which probably means there's lower risk for the scale to overfit with large values. 

That being said, I'll probably switch to a half normal or half-t. As a follow-up, is there a non-aesthetic reason why I might prefer one of those two over the other?

Thanks again!
Ted

Andrew Gelman

unread,
Mar 24, 2016, 6:55:43 PM3/24/16
to stan-...@googlegroups.com
Hi, in answer to your final question, ultimately the choice of prior depends on the population of true parameter values you might be encountering.  Half-t is more appropriate if there might be a few big ones.
A

Ted Papalex

unread,
Mar 24, 2016, 7:04:43 PM3/24/16
to Stan users mailing list
Though I've been convinced to move away from the scale cauchy now, I was wondering why you said I shouldn't need to reparametrize? Would it not provide a speed up?

Thanks!
Ted

Michael Betancourt

unread,
Mar 24, 2016, 7:15:06 PM3/24/16
to stan-...@googlegroups.com
Such reparameterizations aren’t so much for increased speed but rather
improved robustness.  Cauchy’s are difficult to sample because the heavy
tails take forever to explore, but an auxiliary parameterization yields much
nicer tails at the expense of the extra parameters.  Whether the expense
is worth it or not depends on how much time you end up spending in the
tails — if you have lots of data then the posterior will have nice tails and
it won’t matter, but if you have sparse data then it could make a significant
difference.
Reply all
Reply to author
Forward
0 new messages