Quantcast

Gelman 2006 half-Cauchy distribution

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Gelman 2006 half-Cauchy distribution

cddesjar
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.

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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gelman 2006 half-Cauchy distribution

Uwe Ligges-3


Am 28.05.2010 15:29, schrieb Christopher David Desjardins:
> 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)


This won't pass location and scale to dcauchy.

You need something along the lines

   dcauchy0_25 <- function(x) dcauchy(x, location=0, scale=25)
   curve(dcauchy0_25, from=0, to=200)

Uwe Ligges



> 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.
>
> 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
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gelman 2006 half-Cauchy distribution

cddesjar
Thanks that works. I am presuming that the density on the Y-axis would
be wrong in the case of a half-Cauchy distribution and in fact should be
doubled if it's folded at 0?
Chris

On 05/28/2010 09:02 AM, Uwe Ligges wrote:

>
>
> Am 28.05.2010 15:29, schrieb Christopher David Desjardins:
>> 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)
>
>
> This won't pass location and scale to dcauchy.
>
> You need something along the lines
>
>   dcauchy0_25 <- function(x) dcauchy(x, location=0, scale=25)
>   curve(dcauchy0_25, from=0, to=200)
>
> Uwe Ligges
>
>
>
>> 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.
>>
>> 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
>>
>> ______________________________________________
>> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gelman 2006 half-Cauchy distribution

Berwin A Turlach
In reply to this post by cddesjar
G'day Chris,

On Fri, 28 May 2010 08:29:30 -0500
Christopher David Desjardins <[hidden email]> 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)

Which version of R do you use?  This command creates 12 warnings under
R 2.11.0 on my linux machine.  

Reading up on the help page of curve() would make you realise that you
cannot pass the location and scale parameter to dcauchy in the manner
you try.  I guess you want:

R> prior <- function(x) 2*dcauchy(x,location=0, scale=25)
R> curve(prior, from=0, to=200)

or, more compactly,

R> curve(2*dcauchy(x, location=0, scale=25), from=0, to=200)

Cheers,

        Berwin

========================== Full address ============================
Berwin A Turlach                      Tel.: +61 (8) 6488 3338 (secr)
School of Maths and Stats (M019)            +61 (8) 6488 3383 (self)
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway                  
Crawley WA 6009                e-mail: [hidden email]
Australia                        http://www.maths.uwa.edu.au/~berwin

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gelman 2006 half-Cauchy distribution

cddesjar
Perfect. Thanks.
Also using R 2.11.0 on Fedora I didn't get any warnings with my command.
Chris

On 05/28/2010 09:09 AM, Berwin A Turlach wrote:
> curve(2*dcauchy(x, location=0, scale=25), from=0, to=200)
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gelman 2006 half-Cauchy distribution

Duncan Murdoch-2
In reply to this post by cddesjar
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
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gelman 2006 half-Cauchy distribution

Duncan Murdoch-2
In reply to this post by cddesjar
On 28/05/2010 10:14 AM, Christopher David Desjardins wrote:
> Perfect. Thanks.
> Also using R 2.11.0 on Fedora I didn't get any warnings with my command.
>  

That's a serious problem.  Can you give more details (i.e. just plain R,
R under ESS, etc.)?

Duncan Murdoch

> Chris
>
> On 05/28/2010 09:09 AM, Berwin A Turlach wrote:
> > curve(2*dcauchy(x, location=0, scale=25), from=0, to=200)
> >
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Loading...