Credible interval for gamma prior

bayesianconfidence intervalprobability distributionsstatistics

Let's cosnider $X_1, X_2,…,X_n \sim \textrm{Poisson}(\lambda)$ i.i.d, and $\textrm{Gamma}(\alpha, \beta)$ as prior. Then posterior distribuion is $\textrm{Gamma}(\sum_i{X_i} + \alpha, n + \beta)$. We can deduce that bayesian estimator will be given as:
$$\hat T = \frac{\sum X_i + \alpha}{n + \beta}$$

I want to ask you for help in finidng $(1-c)$ credible interval for this problem. I've read that credible interval is such interval $(l, r)$ that satisfies:
$$\int_l^r p(\theta \mid x) = 1 – c$$

But I'm not sure how to derive this with it. Do you know how this $l, r$ can be derived?

Best Answer

If you find $r$ such that $$\int_0^r p(\theta | x) = 1-c/2$$ and $l$ such that $$\int_0^l p(\theta | x) = c/2$$ Then $(l,r)$ is a credible interval because $$\int_l^r p(\theta | x) = 1-c$$

The value of $r$ satisfying the above is, by definition, the quantile function (inverse of the CDF) evaluated at $1-c/2$. The quantile function of the gamma distribution does not have a convenient closed form but can be approximated. In R, you can use qgamma.

You can also obtain a credible interval by sampling from the posterior distribution. I.e., take $10000$ samples from a $\text{Gamma}(X_i + \alpha, n + \beta)$ and look at the empirical quantiles. This is oftentimes the only available option when the models get more complicated...