# Using JAGS for bayesian parameter estimation

I am using JAGS in R to construct a probabilistic graph model and estimate the corresponding parameters. The models is described as follows:

model
{

for (i in 1:N)

{

# sample the hidden variable

z[i]  ~ dbeta(alpha+0.01,beta)T(0,0.9999)

# determined relation
lambda[i] <- z[i] * mu
# conditional data likelihood
X[i] ~ dpois(lambda[i])
}

# prior probability
alpha ~ dgamma(0.1,0.0001)
beta ~ dgamma(0.1,0.0001)
mu ~ dgamma(0.1,0.0001)

}


where X[1:N] is the training samples, which are generated according to a Poisson distribution. The Poisson mean is also a random variable, which is denoted as mu*z. z is a hidden variable following a Beta distribution parametrized by variables alpha and beta. The parameters of this probabilistic model are mu, alpha and beta, and they follow Gamma distribution. I tested this model on a simulated set of data samples:

library('rjags')

N=5000

lambda=rbeta(N,0.2,0.3)*15 #alpha = 0.2,beta = 0.3 and mu = 15

X=rpois(N,lambda)

jags = jags.model('poissontrunc.bugs',data = list('X' = X, 'N' = N),
n.chains = 4,

mcmc.samples <- coda.samples(jags,
c('alpha', 'beta', 'mu'),
5000)

summary(mcmc.samples)


The MCMC-based parameter estimation results are as follows:

Empirical mean and standard deviation for each variable, plus standard error of the mean:

         Mean      SD     Naive SE   Time-series SE

alpha  951.13,    35.0186,   0.247619,    9.72810
beta  1013.24,   26.4553,   0.187068,     7.13232
mu      12.47,   0.3134,    0.002216,     0.08993


The sampling results give the right estimate of the true mu (12.47 vs. 15). However, for alpha and beta, it seems that the estimated values are severely biased (951.13 vs 0.2, 1013.24 vs 0.3). Even considering the variance of the sampling results, estimates for alpha and beta are still far from satisfaction. Is this a problem caused by any potential improper setting of the MCMC sampling, or perhaps MCMC is blocked within the local optimum region of a multi-modal conditional distribution in this case ?

• Those priors aren't very good ones - going to $\infty$ near 0 in all three cases with means of 1000, if I recall the JAGS parameterization correctly - and I'd suggest rerunning the analysis with different ones. Try something along the lines of alpha ~ dunif(0.001,2.0) and same for beta, and mu ~ dunif(1,30) just to try out the code and see if it is the priors doing you in. – jbowman Oct 2 '13 at 21:06
• Thanks for the answer :). Indeed, dunif with this setting gives more consistent estimation results. – Yufei Oct 3 '13 at 9:39