PE = 47/80   
PE 
## [1] 0.5875

This point estimate is calculated using the classical method which is to divide the number of successes by its total observation.Based on the result, we can say that approximately 59% of the participants are said to be lactose intolerant.

p=seq(0.4,0.7, by=0.1)
prior= c(0.1,0.2,0.44,0.26)
likelihood=p^{47}*(1-p)^{33}
PL= prior*likelihood
posterior= PL/sum(PL)
bayesbox=as.data.frame(cbind(p,prior,likelihood,PL,posterior))
kable(bayesbox)  
p prior likelihood PL posterior
0.4 0.10 0 0 0.0006491
0.5 0.20 0 0 0.1135404
0.6 0.44 0 0 0.8337986
0.7 0.26 0 0 0.0520119
mean=sum(p*posterior)
mean
## [1] 0.5937173
var=var(posterior)
var
## [1] 0.1536057

In (a), we came up with the bayesian estimate of approximately 0.6 because we calculate its mean. This means that there is a very slight difference in the value of \(p\) between (a) and (b) with variance of approximately 0.154.

p=seq(0.4,0.7, by=0.1)
prior1= c(0.1,0.2,0.44,0.26)
likelihood1=p^{470}*(1-p)^{330}
PL1= prior1*likelihood1
posterior1= PL1/sum(PL1)
bayesbox1=as.data.frame(cbind(p,prior1,likelihood1,PL1,posterior1))
kable(bayesbox1)
p prior1 likelihood1 PL1 posterior1
0.4 0.10 0 0 0.0000000
0.5 0.20 0 0 0.0000026
0.6 0.44 0 0 0.9999974
0.7 0.26 0 0 0.0000000
BE=sum(p*posterior1)
BE
## [1] 0.5999997
BV= var(posterior1)
BV
## [1] 0.2499982

The posterior changed because of the different sample size, which is much larger,but its mean is approximately 0.6. Moreover, the variance becomes larger which means that the posterior in (c) has higher variability compared to (b) D.

p=seq(0.4,0.7, by=0.1)
prior2= posterior
likelihood2=p^{470}*(1-p)^{330}
PL2= prior2*likelihood2
posterior2= PL2/sum(PL2)
bayesbox2=as.data.frame(cbind(p,prior2,likelihood2,PL2,posterior2))
kable(bayesbox2)
p prior2 likelihood2 PL2 posterior2
0.4 0.0006491 0 0 0.0000000
0.5 0.1135404 0 0 0.0000008
0.6 0.8337986 0 0 0.9999992
0.7 0.0520119 0 0 0.0000000
BE2= sum(p*posterior2)
BE2
## [1] 0.5999999
BV2= var(posterior2)
BV2
## [1] 0.2499995

Based on the results, we have the mean and variance of approximately 0.6 and approximately 0.25,respectively. This means that the value of \(p\) that has the highest posterior based on the new prior is \(p=0.6\) followed by \(p=0.4\).We can see in the posterior and mean that they are just approximately the same but the variance is higher compared to (b) which means that there is higher variability of posterior in (d).