Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cauchy prior in JAGS

Tags:

r

bayesian

jags

I'm building a multi-level Bayesian model using rJAGS and I would like to specify a Cauchy prior for several of my parameters. Is there a way to do this in JAGS, or do I need to switch to STAN? My JAGS model is below. I'd like to replace the dnorm distributions with Cauchy, but JAGS cannot find the standard R Cauchy distributions, e.g. dcauchy, pcauchy

model_string <- "model{
for (i in 1:n){
    y[i] ~ dbin(mu[i], 1) 
p.bound[i] <- max(0, min(1, mu[i])) #381 gelman
logit(mu[i]) <- a[dc[i]] + b1*x1[i] + b2*x2[i]
}

b1 ~ dnorm(0,.001) 
b2 ~ dnorm(0,.001) 

for (j in 1: n.dc ){
    a[j] ~ dnorm(g0, tau.a)  #not goj, g1j
}

g0 ~ dnorm(0,.001) 
tau.a <- pow(sigma.a , -2)
sigma.a ~ dnorm(0,.001) 
}"
like image 849
Emily Avatar asked Jan 21 '16 22:01

Emily


1 Answers

The Cauchy distribution is a special case of the t distribution, with 1 degree of freedom (Wikipedia link). While JAGS does not have the Cauchy, it does have the t distribution.

dt(mu, tau, k)

Just set k equal to 1 and you have a Cauchy prior

dt(mu, tau, 1)

I would not set your variance to a normal or Cauchy prior though, considering that variance is always positive (and the normal or Cauchy is not). Try something like the gamma distribution for your precision.

tau.a ~ dgamma(0.001,0.001) # vague precision parameter
sigma.a <- 1/sqrt(tau.a)
like image 113
mfidino Avatar answered Sep 30 '22 05:09

mfidino