half-Cauchy distribution in rstan

Hi, I have to implement half-Cauchy distribution and Cauchy distribution in rstan.

For example, If I assume tausq follows half-Cauchy (0,5) where 0 is for location parameter and 5 is the scale parameter. I found on the web I can use the Cauchy function in the model block. Then, could I put my tausq in model block as follows?

model {
// Priors
tausq ~ cauchy(0, 5);
}

I am confused because this is not different from Cauchy distribution. For example, If I want to use delta which does follow the cauchy(0,5),

model {
// Priors
delta ~ cauchy(0, 5);
}

I can’t find the difference.

Could you please help me?

Thanks for your help.

By restricting tausq in the parameters block to be strictly positive

parameters {
  real<lower=0>tausq;
}

model {
  tausq~cauchy(0,5);
}

We obtain the half-cauchy prior (up until an additive constant on the log scale)

If the parameter is unconstrained

parameters {
  real delta
}

model{
  delta ~ cauchy(0,5);
}

It is the cauchy prior.

2 Likes

Thank you so much for your help!