Some examples

Let us illustrate these ideas with a simple case on which exact calculations can be also done: the inference of $p$ of a binomial distribution, based on $n$ successes got in $N$ trials. We went through it in Sec. [*], but we do it solve it now with JAGS in order to provide some details on `reshaping'. The model is really trivial
model {
  n ~ dbin(p, N)
  p ~ dbeta(r0,s0)   
}
and the full script is provided in Appendix B.12. For $N=10$ and $n=3$ and a flat prior the JAGS result is shown by the histogram of Fig. [*].
Figure: Inference of $p$ with binomial distributions obtained with different priors and different ways to make use of an `informative prior' (see text).
\begin{figure}\begin{center}
\epsfig{file=test_reshape.eps,clip=,width=\linewidth}
\\ \mbox{} \vspace{-1.1cm} \mbox{}
\end{center}
\end{figure}
The blue line along the profile of the histogram is the analytic result obtained starting from of a Beta prior with $r_0=s_0=1$, that is Beta$(1\!+\!n,\, 1\!+\!N\!-\!n)$. Then the `informative prior' (rather vague indeed), modeled by a Beta$(4, 2)$ and therefore having a mean value of $4/(4+2)=2/3$, is shown by the magenta curve having the maximum value at $3/4\,=[(4-1)/(4+2-2)]$. The distribution obtained reweighing the posterior got from a flat prior (histogram) by this new prior is shown by the blue broken curve, while the red broken curve shows the JAGS result obtained using the new prior (the latter curves overlap so much that they can only be identified by color code). Finally, the green continuous curve is the analytic posterior obtained updating the Beta parameters, that is Beta$(4\!+\!3,\, 2\!+\!7)$. The agreement of the three results is `perfect' (taking into account that two of them are got by sampling).

The second example is our familiar case of 2010 positives in a sample of 10000 individuals shown in detail in Sec. [*] and of which a different Monte Carlo run, with $n_r=4\times 10^6$ in order to get a smoother histogram, is shown in Fig. [*].

Figure: Inference of the proportion $p$ of infected in a population, having measured 2010 positives in a sample of 10000 individuals: JAGS result based on a flat prior (histograms) and effect of `reshaping' based on an informative prior. (see text).
\begin{figure}\begin{center}
\epsfig{file=inf_p_reshape_pub.eps,clip=,width=\linewidth}
\\ \mbox{} \vspace{-1.1cm} \mbox{}
\end{center}
\end{figure}
The new prior is indicated by the magenta curve, modeled by a Beta$(6,14)$, having its mode at $5/18\approx 0.28$. The reshaped posterior is indicated by the blue curve, having mean $0.1134$ and standard deviation $0.0182$. The result of JAGS using as prior the Beta$(6,14)$ is shown by the red curve, characterized by a mean of 0.1145 and a standard deviation 0.0184 (we are using an exaggerated number of digits just for checking - using one digit for the uncertainty both results become ` $0.11\pm 0.02$'). The degree of agreement is excellent, also taking into account that they have intrinsic Monte Carlo fluctuations. It is interesting to note that, besides increasing slightly the mean values (but one could object that “they are equal within the uncertainties”), the main effect of the new prior is to practically rule out values of $p$ below 0.05.