Ex.
suppose that $x=2$ denotes the number of successes in $n=5$ independent trials with probability $θ$ of success, that is $x$ has a binomial distribution with the parameters $n=5$ and $ θ$. assuming that the parameter $θ $ has a uniform(zero,1) prior density:
(a)find posterior density function, and hence the posterior mean of $θ$.
(b)find a two tailed $90$% credibility interval for θ in terms of the inverse posterior distribution function.
(c) test the hypothesis$ H:θ=0.3 vs A:θ≠0.3 $, assuming that the prior probabilities of H and A are equal.
Suggested answer
(a) Posterior $ 1/β(3,4) * θ^2 * (1-θ)^3 $, and mean $3/7$ .
(b) Two tailed 90% credibility interval calculate it from $x ̅±z_(α/2) *σ,x ̅=3/7 , z_(α⁄2) =1.65 , σ=√(3/98) $ .
(but i do not understand meaning of "in terms of the inverse posterior distribution function")
(c) Calculate from
$ p(H|x)/p(A|x)=p(H)/P(A) * P(x|H,θ)/∫P(x│A,θ) P(θ) dθ $
Where $P(H)=P(A)=.5$ ,
$P(x|H,θ)= 10 * (.3)^2 * (.7)^3 =0.3087 , ∫P(x│A,θ)* P(θ) dθ =(10/√2π)∫θ^2 (1-θ)^3 exp(-.5 x^2) dθ ,x=2$.
and finally result $p(H|x)/p(A|x)=.00129 <1 $, then reject $A:θ≠0.3$
Please tell me about my answers true or false and in (b) what mean about terms of the inverse?
Any help would be appreciated
Thank you so much!
The prior distribution is $UNIF(0,1) \equiv BETA(1,1)$ with density function $p(\theta) = \theta^{\alpha_0 - 1}(1 - \theta)^{\beta_0 - 1},$ where $0 \le \theta \le 1$ and $\alpha_0 = \beta_0 = 1.$
The likelihood function is proportional to $\theta^2(1-\theta)^{n-2},$ where $n = 5.$
The posterior distribution is found as $$Posterior \propto Prior \times Likelihood.$$
So your posterior distribution is (proportional to) $$p(\theta|x) = \theta^{3 - 1} (1 - \theta)^{4 - 1},$$
which is $Beta(3, 4).$
Therefore, a 90% posterior probability interval can be found by cutting 5% from each tail of $Beta(3,4).$
In R, this can be evaluated as $(.153, .729)$:
The posterior is BETA(3,4), and the quantile function of a beta distribution (inverse CDF) is called
qbetain R.Note: You seem to be using a normal approximation to this beta distribution, which is not something I would do.
I will leave the test of hypothesis to you.