**6.3 Checking of prior data conflict for binomial distribution**

Suppose that we have a sample that follows the binomial distribution and in short x � bin (n,p) and as shown in the Eq. (40) then we need to determine the prior distribution through two methods [14]:

**The first method**: It is the Expected Conditional method we have previously explained this method so we go through the following steps [9]:

$$\mathbf{E}(\mathbf{p}/\mathbf{a}, \emptyset) = \mathbf{y}^0 = \frac{\mathbf{a}}{\mathbf{a} + \emptyset}$$

*Robust Bayesian Estimation DOI: http://dx.doi.org/10.5772/intechopen.104090*

$$\mathbf{y}^0 = \frac{\alpha}{\mathbf{n}^0}, \text{ where } \mathbf{n}^0 = \alpha + \boldsymbol{\beta}$$

$$\mathbf{y}^0 = \frac{\alpha}{\mathbf{n}^0} \Rightarrow \mathbf{a} = \mathbf{n}^0 \mathbf{y}^0, \mathbf{n}^0 = \mathbf{n}^0 \mathbf{y}^0 + \boldsymbol{\beta} \Rightarrow \boldsymbol{\beta} = \mathbf{n}^0 (\mathbf{1} - \mathbf{y}^0)$$

Then we substitute the parameters <sup>α</sup> <sup>¼</sup> n0y0, <sup>β</sup> <sup>¼</sup> n0 <sup>1</sup> � y0 with the prior distribution to get the prior distribution with the updated parameters:

$$\mathbf{f}\left(\mathbf{p}/\mathbf{n}^{0},\mathbf{y}^{0}\right) = \frac{\mathbf{1}}{\mathfrak{F}\left(\mathbf{n}^{0}\mathbf{y}^{0},\mathbf{n}^{0}(\mathbf{1}-\mathbf{y}^{0})\right)}\mathbf{p}^{\mathbf{n}^{0}\mathbf{y}^{0}-1}(\mathbf{1}-\mathbf{p})^{\mathbf{n}^{0}\left(1-\mathbf{y}^{0}\right)-1} \tag{47}$$

**The second method**: In this method the prior distribution can be determined with the updated parameters through two steps, which are as follows [10]:

**The first step**: If the model can be written in the form of canonical exponential family, as shown below:

$$\begin{aligned} \mathbf{f}(\mathbf{x}/\mathbf{p}) &= \mathbf{a}(\mathbf{x}) \exp\left(\boldsymbol{\upmu}.\tau(\mathbf{x}) - \mathbf{n}(\boldsymbol{\upmu})\right) \\ \mathbf{f}(\mathbf{s}/\mathbf{p}) &= \begin{pmatrix} \mathbf{n} \\ \mathbf{s} \end{pmatrix} \mathbf{p}^s (\mathbf{1} - \mathbf{p})^{\mathbf{n} - \mathbf{s}} \\ \mathbf{s} &= \begin{pmatrix} \mathbf{n} \\ \mathbf{s} \end{pmatrix} \exp\left\{ \ln \left( \frac{\mathbf{p}}{\mathbf{1} - \mathbf{p}} \right) \mathbf{s} - \mathbf{n}(-\ln(1 - \mathbf{p})) \right\} \\ \mathbf{a}(\mathbf{x}) &= \begin{pmatrix} \mathbf{n} \\ \mathbf{s} \end{pmatrix}, \boldsymbol{\upmu} = \ln \left( \frac{\mathbf{p}}{\mathbf{1} - \mathbf{p}} \right), \boldsymbol{\uppi}(\mathbf{x}) = \mathbf{s}, \mathbf{b}(\boldsymbol{\upmu}) = -\ln(\mathbf{1} - \mathbf{p}) \end{aligned} \tag{48}$$

**The second step**: the prior distribution can be built by using the following model:

$$\mathbf{f}\left(\mathbf{w}/\mathbf{n}^{0},\mathbf{y}^{0}\right)\mathbf{d}\boldsymbol{\upmu}\propto\exp\left\{\mathbf{n}^{0}\left[\mathbf{y}^{0},\mathbf{w}-\mathbf{b}(\boldsymbol{\upmu})\right]\right\}\mathbf{d}\boldsymbol{\upmu}$$

$$\mathbf{f}\left(\mathbf{w}/\mathbf{n}^{0},\mathbf{y}^{0}\right)\mathbf{d}\boldsymbol{\upmu}\propto\exp\left\{\mathbf{n}^{0}\left[\mathbf{y}^{0}\ln\left(\frac{\mathbf{p}}{\mathbf{1}-\mathbf{p}}\right)+\ln\left(\mathbf{1}-\mathbf{p}\right)\right]\right\}\mathbf{d}\boldsymbol{\upmu}$$

$$\left|\frac{\mathbf{d}\boldsymbol{\upmu}}{\mathbf{d}\mathbf{p}}\right|=\frac{1}{\mathbf{p}(1-\mathbf{p})}$$

$$\mathbf{f}\left(\mathbf{p}/\mathbf{n}^{0},\mathbf{y}^{0}\right)\mathbf{d}\mathbf{p}=\mathbf{f}\left(\mathbf{w}/\mathbf{n}^{0},\mathbf{y}^{0}\right)\left|\frac{\mathbf{d}\mathbf{w}}{\mathbf{d}\mathbf{p}}\right|\mathbf{d}\mathbf{p}$$

$$\propto\exp\left\{\mathbf{n}^{0}\mathbf{y}^{0}\ln\left(\mathbf{p}\right)+\left(\mathbf{n}^{0}-\mathbf{n}^{0}\mathbf{y}^{0}\right)\ln\left(\mathbf{1}-\mathbf{p}\right)\right\}\frac{\mathbf{1}}{\mathbf{p}(1-\mathbf{p})}\,\mathbf{d}\mathbf{p}$$

Then the prior distribution with the updated parameters is:

$$\mathbf{f}\left(\mathbf{p}/\mathbf{n}^{0},\mathbf{y}^{0}\right) = \frac{1}{\beta\left(\mathbf{n}^{0}\mathbf{y}^{0},\mathbf{n}^{0}(1-\mathbf{y}^{0})\right)}\mathbf{p}^{\mathbf{n}^{0}\mathbf{y}^{0}-1}(1-\mathbf{p})^{\mathbf{n}^{0}\left(1-\mathbf{y}^{0}\right)-1} \tag{49}$$

From the above equation, we extract the standard deviation of the prior distribution, as follows:

$$\begin{split} \mathbf{M}\_{\mathbf{r}} &= \frac{1}{\mathfrak{P}(\mathbf{n}^{0}\mathbf{y}^{0}, \mathbf{n}^{0}(1-\mathbf{y}^{0}))} \Bigg\Big\{ \mathbf{p}^{\mathbf{n}^{0}\mathbf{y}^{0}+\mathbf{r}-1}(\mathbf{1}-\mathbf{p})^{\mathbf{n}^{0}\{1-\mathbf{y}^{0}\}-1} \mathbf{d}\mathbf{p} \\ &= \frac{1}{\mathfrak{P}(\mathbf{n}^{0}\mathbf{y}^{0}, \mathbf{n}^{0}(1-\mathbf{y}^{0}))} \mathfrak{P}(\mathbf{n}^{0}\mathbf{y}^{0}+\mathbf{r}, \mathbf{n}^{0}(1-\mathbf{y}^{0})) \\ &= \frac{\mathbf{r}(\mathbf{n}^{0}\mathbf{y}^{0}+\mathbf{n}^{0}(1-\mathbf{y}^{0}))}{\mathbf{r}(\mathbf{n}^{0}\mathbf{y}^{0})\mathbf{r}(\mathbf{n}^{0}(1-\mathbf{y}^{0}))} \frac{\mathbf{r}(\mathbf{n}^{0}\mathbf{y}^{0}+\mathbf{r})\,\mathbf{r}(\mathbf{n}^{0}(1-\mathbf{y}^{0}))}{\mathbf{r}(\mathbf{n}^{0}\mathbf{y}^{0}+\mathbf{r}+\mathbf{n}^{0}(1-\mathbf{y}^{0}))} \\ &= \frac{\mathbf{r}(\mathbf{n}^{0})\,\mathbf{r}\left(\mathbf{n}^{0}\mathbf{y}^{0}+\mathbf{r}\right)}{\mathbf{r}(\mathbf{n}^{0}\mathbf{y}^{0})\mathbf{r}(\mathbf{n}^{0}+\mathbf{r})} \\ \end{split} \tag{50}$$

$$\text{s.d prior} = \sqrt{\frac{\mathbf{y}^0 (\mathbf{1} - \mathbf{y}^0)}{\mathbf{n}^0 + \mathbf{1}}} \tag{51}$$

$$\mathbf{f}(\mathbf{p}/\mathbf{s}) = \mathbf{f}(\mathbf{p}/\mathbf{n}^\mathbf{n}, \mathbf{y}^\mathbf{n})$$

Then the standard deviation of the posterior distribution is according to the following formula:

$$\text{s.d. posterior} = \sqrt{\frac{\mathbf{y}^{\text{n}}(\mathbf{1} - \mathbf{y}^{\text{n}})}{\mathbf{n}^{\text{n}} + \mathbf{1}}} \tag{54}$$
