logo

Bayesian Inference for Binomial Distribution

   

Added on  2023-05-31

7 Pages1033 Words353 Views
 | 
 | 
 | 
Name:
Institution:
1
Bayesian Inference for Binomial Distribution_1

Assignment solutions
1
(A) X1 , ... , Xn Bin ( n , θ )
Prior unif ( 0,1 )
Posterior likelihood × prior distribution CITATION Mon92 \l 1033 (Monahan & Boos, 1992)
¿
Constant
×θ
i=1
n
X i
(1θ)n¿
i=1
n
Xi ¿
θ
i=1
n
X i
( 1θ )n¿
i=1
n
Xi ¿
Beta (
i=1
n
X i+1 , n
i=1
n
Xi +1 )
(B) The codes and the results are given as below ( copy-pasted from R-console):
Codes
library(Bolstad)
## assuming x=5 successes in n=10 trials
##unif(0,1)is the same as beta(1,1)
kiwi<-binobp(x=5, n=10, a = 1, b = 1, pi = seq(0, 1, by = 0.001), plot = TRUE)
attributes(kiwi)
ki<-kiwi$mean
ki
kii<-kiwi$sd
kii
kiii<-kiwi$var
kiii
##p1 is parameter 1, p2 is parameter 2 that is and b respectively
p1_plus_p2<-(ki*(1-ki)/kiii)-1
p1_plus_p2
newp1<-ki*p1_plus_p2
newp1
newp2<-p1_plus_p2-newp1
newp2
#median
qbeta(0.5,newp1,newp2)
#95% confidence interval
qbeta(0.025,newp1,newp2)
qbeta(0.975,newp1,newp2)
output
> kii<-kiwi$sd
2
Bayesian Inference for Binomial Distribution_2

> kii
[1] 0.138675
> kiii<-kiwi$var
> kiii
[1] 0.01923077
> ##p1 is parameter 1, p2 is parameter 2 that is and b respectively
> p1_plus_p2<-(ki*(1-ki)/kiii)-1
> p1_plus_p2
[1] 12
> newp1<-ki*p1_plus_p2
> newp1
[1] 6
> newp2<-p1_plus_p2-newp1
> newp2
[1] 6
> #median
> qbeta(0.5,newp1,newp2)
[1] 0.5
> #95% confidence interval
> qbeta(0.025,newp1,newp2)
[1] 0.2337936
> qbeta(0.975,newp1,newp2)
[1] 0.7662064
Plot
3
Bayesian Inference for Binomial Distribution_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Summary on Goodness of Fit
|15
|2786
|69

Mathematical Theory of Risk Assignment 1
|6
|677
|238

Bayesian Approach Assignment
|11
|1406
|202

Dimensions and Equations in Physics
|10
|1331
|97

Digital Communication System and Bi-orthogonal Signal Constellation
|12
|2496
|232