0
$\begingroup$

I'm trying to make a "triplot" to illustrate Bayesian inference (so I'd like to have prior, likelihood and posterior in the same picture). For likelihood I'm using \begin{equation}\label{eq:lik} f(y|\tau) = \prod_{i=1}^{n}\frac{\tau}{\sqrt{2\pi}}\exp\left(-\frac{\tau(y_{i}-\mu)^{2}}{2}\right) = \frac{\tau}{\sqrt{2\pi}}\exp\left(-\frac{\tau\sum_{i=1}^{n}(y_{i}-\mu)^{2}}{2}\right), \end{equation} i.e., the Gaussian distribution with known mean $\mu$ and unknown precision $\tau=\frac{1}{\sigma}$, where ${\sigma}^{2}$ is the unknown variance.
If we choose the prior on $\tau$ to be a gamma distribution \begin{equation} p(\tau)=\Gamma(\alpha,\beta), \end{equation} with the shape $\alpha$ and the rate $\beta$, we can use the conjugacy theory to find the form of the posterior. The posterior distribution in our example is the following gamma distribution \begin{equation} p(\tau|y)=\Gamma\left(\alpha+\frac{n}{2},\beta+\frac{\sum_{i=1}^{n}(y_{i}-\mu)^{2}}{2}\right). \end{equation} I plotted it with $\alpha=1.5$, $\beta=10.0$, $\mu=0.0$ $n=5$ and the random sample $(y_i)_{i=1\dots 5}$ was generated assuming the "true" value of $\tau=0{.}25$. As you can see, the likelihood is not visible. I tried different configurations of parameters but nothing helped.
I'd be very grateful for any ideas how to choose $\alpha$ and $\beta$ so that I get a nice illustration, something like that.

$\endgroup$
7
  • 1
    $\begingroup$ Hint: normal distribution does not range from 0 to 2, but can take also negative values. Hight of densities can also vary for different distributions. $\endgroup$
    – Tim
    Commented Aug 24, 2016 at 10:02
  • $\begingroup$ @Tim, I'm aware of that. I chose (0,2) "just because" but I tried different axes. I know the hight varies but whatever I try, prior and posterior are much "higher" than the likelihood. This is why I asked for help. $\endgroup$
    – Paula
    Commented Aug 24, 2016 at 10:06
  • 1
    $\begingroup$ ...and they will be. If it's just for illustration purpose then you can simply multiply the likelihood by some arbitrary constant to "look nice". $\endgroup$
    – Tim
    Commented Aug 24, 2016 at 10:09
  • 2
    $\begingroup$ Imagine that you plotted three continuous uniform distributions with ranges 1, 50, and 5000, they will have heights 1, 1/50 and 1/5000 -- this is how densities work, so if you want them to have "similar" heights then you need to rescale them. $\endgroup$
    – Tim
    Commented Aug 24, 2016 at 10:16
  • 1
    $\begingroup$ The likelihood is not a density in the parameter and the likelihood principle tells you it is defined up to a constant. Renormalising it is thus not cheating! $\endgroup$
    – Xi'an
    Commented Aug 25, 2016 at 3:14

1 Answer 1

0
$\begingroup$

The method is very easy: I'll rescale the likelihood which is fine because it doesn't have to integrate to 1.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.