# Find Bayes Estimator when Kernel of posterior is not clear

Suppose $$x\mid\theta \sim \operatorname{Gamma}(\frac{n}{2},2\theta)$$ and $$\theta \sim$$ inverse Gamma$$(\alpha, \beta)$$

with loss function $$L(\theta, d)=\frac{(\theta-d)^2}{\theta^2}$$

We wish to find the Bayes estimator, ie the estimator minimizing posterior expected loss. If it was square error loss, then it would simply be the posterior mean. But since not, we must minimize the estimator with respect to the expected posterior loss.

Issues occur in that there is no obvious distribution for the posterior or way to evaluate the integrals.

The question appeared on a past exam. User Xi'an left the very interesting note that we could transfer the denominator of the loss function to our prior and then we would have the standard square error loss. In that case it would be a matter of finding the mean of the resulting posterior distribution. But I am seeing slightly different answers, as well as the answer I was given was the quotient of two non standard integrals and involved differentiating under the integral sign.

• You should add the self-study tag to your question. Adding $\theta^{-2}$ to the quadratic loss is equivalent to adding $\theta^{-2}$ to the prior: switch to an Inverse Gamma with parameter $\alpha+2$ instead and use the posterior mean. Nov 2 '18 at 5:07
• @Xi'an Tag added. Not Homework by the way. I see. Because it will all be the same when you to integrate. But is the resulting kernel a standard distribution? Nov 2 '18 at 5:11
• Since Inverse Gamma is conjugate to Gamma in this case, everything remains standard. Nov 2 '18 at 5:14
• Very nice. Suppose you didnt switch the prior, would you still get the same result, just with the ugly integrals? Nov 2 '18 at 5:23
• This duality is covered in my book, The Bayesian Choice, Chapter 3 Nov 2 '18 at 11:57

All of this can be solved analytically, since your prior distribution is the conjugate prior. From the specified distributions you have:

$$L_x(\theta) = \theta^{-n/2} \exp \Big( -\frac{x}{2\theta} \Big) \quad \quad \quad \pi(\theta) \propto \theta^{-\alpha-1} \exp \Big( -\frac{\beta}{\theta} \Big).$$

So the posterior is:

\begin{aligned} \pi(\theta|x) &\propto \theta^{-n/2} \exp \Big( -\frac{x}{2\theta} \Big) \cdot \theta^{-\alpha-1} \exp \Big( -\frac{\beta}{\theta} \Big) \\[6pt] &= \theta^{-(\alpha+n/2)-1} \exp \Big( - \Big( \beta+\frac{x}{2} \Big) \frac{1}{\theta} \Big) \\[6pt] &\propto \text{Inv-Gamma} \Big( \theta \Big| \alpha+\frac{n}{2}, \beta+\frac{x}{2} \Big). \end{aligned}

So you have $$\theta|x \sim\text{Inv-Gamma}(\alpha+n/2, \beta+x/2)$$, which is of the same family as your prior (i.e., this is a conjugate prior). Observation of the data updates the posterior by adding to the initial hyperparameters in the prior. We have $$\theta^{-1}|x \sim\text{Gamma}(\alpha+n/2, \beta+x/2)$$ which means you get the risk function:

\begin{aligned} R(d) &\equiv \mathbb{E}( L(d(x), \theta) |x) \\[6pt] &= \mathbb{E} \Big( \frac{(\theta-d(x))^2}{\theta^2} \Big| x \Big) \\[6pt] &= \mathbb{E} \Big( 1 - \frac{2d(x)}{\theta} + \frac{d(x)^2}{\theta^2} \Big| x \Big) \\[6pt] &= 1 - 2 \mathbb{E}( \theta^{-1} | x) \cdot d(x) + \mathbb{E}( \theta^{-2} |x) \cdot d(x)^2 \\[6pt] &= 1 - 2 \cdot \frac{\alpha+\tfrac{n}{2}}{\beta+\tfrac{x}{2}} \cdot d(x) + \frac{(\alpha+\tfrac{n}{2})(\alpha+\tfrac{n}{2}+1)}{(\beta+\tfrac{x}{2})^2} \cdot d(x)^2. \\[6pt] \end{aligned}

This function is a convex quadratic equation in $$d$$, which can easily be minimised with respect to $$d$$ to give you the Bayes' estimator. Minimisation of the Bayes risk gives the estimator:

$$\hat{\theta} \equiv d(x) = \frac{\beta+\tfrac{x}{2}}{\alpha+\tfrac{n}{2}+1}.$$

• How do you get that likilihood for n from gamma distribution? Just took a quick look Nov 2 '18 at 3:32
• You are missing the data $x$ from your posterior Nov 2 '18 at 4:32
• @probabilityislogic I think he just replaced x with n? Nov 2 '18 at 4:38
• @Ben . Yes he used that convention to be the opposite. I agree it is misleading. Nov 2 '18 at 22:44
• @Quality: Well, I think it is a fair criticism.
– Ben
Nov 2 '18 at 23:15

Ben's answer addresses your question completely. But I wanted to explain what happens in general. The loss function here is an example of a weighted squared error loss function. In general, a weighted squared error loss function can be written as $$L(\theta, d) = \dfrac{(\theta-d)^2}{w(\theta)}\,.$$ For example, in your situation, the weight is $$w(\theta) = \theta^2$$. As you mentioned, the Bayes estimator is the estimator that minimizes the expected posterior loss. That is $$d_{bayes} = \arg\min_d \int L(\theta, d) \pi(\theta|x)d\theta\,.$$

The expected posterior loss is, \begin{align*} \int L(\theta, d) \pi(\theta|x)d\theta & = \int \dfrac{(\theta - d)^2 }{w(\theta)} \dfrac{\pi(x | \theta) \pi(\theta)}{\pi(x)} d\theta\\ & = \int (\theta - d)^2 \dfrac{\pi(x | \theta)}{\pi(x)} \underbrace{\dfrac{\pi(\theta)}{w(\theta)}}_{\text{New prior kernel } \propto \pi'(\theta)}d\theta\\ & \propto \int (\theta - d)^2 \dfrac{\pi(x | \theta)}{\pi(x)} \pi'(\theta)d\theta\\ & = \int(\theta - d)^2 \pi'(\theta|x)d\theta\,. \end{align*} where $$\pi'(\theta|x)$$ is the new posterior distribution resulting from the new prior $$\pi'(\theta)$$. Then the minimizer of this new expected posterior loss, is the posterior mean with respect to $$\pi'(\theta|x)$$.

As probabilityislogic pointed out, the new prior may be improper, in which case the posterior may be improper, but the integral will still accurately represent the expected posterior loss.

• There are obviously caveats here. That new prior may be improper for some choices of weight function. Nov 2 '18 at 11:09
• @probabilityislogic Ah yes, that's correct. I'll edit the answer to indicate that. Nov 2 '18 at 11:47
• It does not really matter that the prior gets proper or improper as long as the posterior loss can be minimised. Nov 2 '18 at 11:56
• @Greenparker: Great answer (+1). Please check my edit to see if it accurately captures your work - reverse if needed.
– Ben
Nov 2 '18 at 22:35
• Thanks @Greenparker I appreciate this answer as well. I think my issue was mainly from the abuse of notation (and simply, wrong notation). But this helps to better my understanding for the future! Nov 3 '18 at 2:02