# precision or variance of a Gamma distribution in a Gibbs Sampler?

I want to confirm my thinking on a quick question I have regarding the Normal-Gamma Gibbs sampler that we see so often, but I am unable to find a satisfactory answer.

If we are interested in inferring $$\mu$$ and $$\sigma^2$$ (the variance) for the following model:

$$y_i \sim \mathcal{N}(\mu, \sigma^2) \\ \mu \sim \mathcal{N}(\mu_0, \tau_0) \\ \frac{1}{\sigma^2} \sim \mathcal{G}\left(\frac{\nu_0}{2}, \frac{\nu_0 \sigma^2_0}{2}\right)$$

And the resulting posterior full conditional distributions:

$$\mu | \sigma^2, y \sim \mathcal{N} \left(\frac{\frac{\mu_0}{\tau_0^2} + \frac{n\bar{y}}{\sigma^2}}{\tau_0^2 + \frac{n}{\sigma^2}}, \frac{1}{\tau_0^2 + \frac{n}{\sigma^2}} \right) \\ \frac{1}{\sigma^2} | \mu, y \sim \mathcal{G} \left( \frac{\nu_0 + n}{2}, \frac{\nu_0 \sigma_0^2 + n S_n^2}{2} \right) \\ \text{where } S_n^2 = \frac{1}{n} \sum_{i = 1}^n (y_i - \mu)^2 \text{ (i.e. the sum of squares for the likelihood distribution)}$$

The model I created in JAGS is as follows:

model {
for (i in 1:n) {
y[i] ~ dnorm(mu, sig2_inv)
}

mu ~ dnorm(mu_0, 1.0/tau_0)
sig2_inv ~ dgamma(nu_0, nu_0_sig2_0)

tau_0 = 0.5
mu_0 = 0.0
nu_0 = 1.0
nu_0_sig2_0 = 0.5

}


The resulting samples from the full conditional gamma distribution will be in terms of precision, correct? So the empirical mean of these samples then estimates precision of the distribution of $$Y_i$$ rather than the variance?

• You see the answer right there in your mathematics (and even in the choice of variable name) -- you're computing the average of $1/\sigma^2$ values (i.e. precision). If you want variances, just invert the individual generated parameter values. – Glen_b Jun 19 at 0:01