[R] Gelman 2006 half-Cauchy distribution
Duncan Murdoch
murdoch.duncan at gmail.com
Fri May 28 16:46:42 CEST 2010
On 28/05/2010 9:29 AM, Christopher David Desjardins wrote:
> Hi,
> I am trying to recreate the right graph on page 524 of Gelman's 2006
> paper "Prior distributions for variance parameters in hierarchical
> models" in Bayesian Analysis, 3, 515-533. I am only interested, however,
> in recreating the portion of the graph for the overlain prior density
> for the half-Cauchy with scale 25 and not the posterior distribution.
> However, when I try:
>
> curve(dcauchy, from=0, to=200, location=0, scale=25)
>
> the probabilities for the half-Cauchy values seem to approach zero
> almost immediately after 0 whereas in Gelman 2006 the tail appears much
> fatter giving non-zero probabilities out to 100.
>
Don't ignore the warnings!!! The scale argument is not being passed to
dcauchy. (Nothing in the help page suggests it would be, but some other
similar functions would have passed it, so I can see how you made the
wrong assumption. But why did you ignore all those warnings?) You'll
get what you want with
curve( dcauchy(x, location=0, scale=25), from=0, to=200)
or with
den <- function(x) dcauchy(x, location=0, scale=25)
curve(den, from=0, to=200)
if you don't like using the magic name "x" in the first one.
Duncan Murdoch
> I am interested in replicating this because I want to use half-Cauchy
> priors and want to play around with the scale values but I want to know
> what my prior looks like before using it in models.
>
> Please cc me as I am digest subscriber.
>
> Thanks!
> Chris
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list